0% found this document useful (0 votes)
26 views2 pages

To Divide 100% Width Equally Betwee

Uploaded by

Zain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

To Divide 100% Width Equally Betwee

Uploaded by

Zain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

To divide 100% width equally between 3 `<div>` elements, you can use **CSS

Flexbox** or **CSS Grid**. Here's how to achieve this:

---

### **Using Flexbox**

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Equal Width Divs</title>
<style>
.container {
display: flex;
width: 100%;
}

.box {
flex: 1; /* Distribute space equally */
border: 1px solid #000;
text-align: center;
padding: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="box">Div 1</div>
<div class="box">Div 2</div>
<div class="box">Div 3</div>
</div>
</body>
</html>
```

---

### **Using CSS Grid**

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Equal Width Divs</title>
<style>
.container {
display: grid;
grid-template-columns: repeat(3, 1fr); /* Divide into 3 equal columns */
width: 100%;
}

.box {
border: 1px solid #000;
text-align: center;
padding: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="box">Div 1</div>
<div class="box">Div 2</div>
<div class="box">Div 3</div>
</div>
</body>
</html>
```

---

### Key Points:


1. **Flexbox**:
- `flex: 1;` ensures that each child `<div>` gets an equal share of the
available space.
2. **Grid**:
- `grid-template-columns: repeat(3, 1fr);` creates 3 equal-width columns.
3. Both methods ensure a responsive layout without hardcoding widths.

Let me know if you'd like further customization!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy