I have 4 images and want them to be displayed 2 on each row. Each of them has a width:50%
and also a float:left
.
HTML
<section class="opportunity">
<div class="main">
<img src="phone.jpg" >
<div class="paragraph">This wil be centered</div>
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="clearfix"></div>
</section>
CSS:
.clearfix{
clear: both;
}
section{
text-align: center;
}
.main{
float:left;
width:50%;
text-align: center;
border:10px solid white;
width:306px;
height:306px;
margin : 50px auto;
box-shadow: 0px 0px 25px black;
overflow: hidden;
}
.paragraph{
-webkit-transform: translateY(-300%);
border: 5px solid grey;
background-color: grey;
opacity: 0.5;
}
.main:hover .content,
.main:active .content{
-webkit-transform: translateY(-340px);
-webkit-transition: -webkit-transform 700ms;
}
.content{
width: 306px;
height: 306px;
background: rgba(51, 102, 255, 0.5);
}
img{
height:inherit;
width:inherit;
-webkit-transition: -webkit-transform 5000ms;
}
button{
width: 100%;
height: 50px;
margin-top: 100px;
background: black;
border: 0;
cursor: pointer;
color: white;
font: 16px tahoma;
}
button:hover
{
opacity: 0.5;
}
The problem is that all of the image are displayed within the same row. The width:50% does not seem to applied. How can I display the images two by two instead of having them all displayed on the same line?