Borders Not Covering Background

How to make a background color not overlap a border?

Simply add overflow:hidden to #container

Demo Fiddle

Note you can also accomplish what you want in a far simpler way:

Demo Fiddle

HTML

<div id="container">
<div id="column2">Column 2</div>
<div id="column1">Column 1</div>
</div>

CSS

#container {
border:5px solid #990000;
overflow:hidden;
border-radius:10px;
}
#column1 {
background-color: cyan;
overflow:hidden;
}
#column2 {
background-color: lime;
float: right;
width: 200px;
}

Why does that border not covering up its contents

That is because of the float: left

Check out how I did it.

.square{      padding-bottom:30%;      width:30%;      margin:10px;       background-color:brown;    }    .container{      height:100%;      max-width:600px;      margin:20px auto;      border:2px solid red;
} .row { display: flex; flex-wrap: wrap; }
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>Document</title></head><body>  <div class="container">
<div class="row"> <div class="square"></div> <div class="square"></div> <div class="square"></div> </div>
<div class="row"> <div class="square"></div> <div class="square"></div> <div class="square"></div> </div> </div>
</body></html>


Related Topics



Leave a reply



Submit