I'm having trouble creating a design similar to the one in this image. When I adjust the browser width, two divs don't remain aligned properly. If I use float: left
for both divs, they stack vertically, but the layout breaks when I resize the screen.
How can I ensure that the divs stay together and within a border, like in the image?
ol {
list-style-type: none;
padding: 0;
}
ol .search-result {
position: relative;
display: block;
min-height: 220px;
color: #000;
padding: 10px 5px;
}
.media-box {
float: left;
}
.search-result-item {
overflow: auto;
max-width: 600px;
padding-top: 7px;
padding-bottom: 7px;
}
.search-item-box {
border: 1px solid #DDD;
min-height: 226px;
transition: box-shadow .2s ease-in-out;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.search-item-box:hover {
-webkit-box-shadow: 14px 13px 20px -9px rgba(0, 0, 0, 0.36);
-moz-box-shadow: 14px 13px 20px -9px rgba(0, 0, 0, 0.36);
box-shadow: 14px 13px 20px -9px rgba(0, 0, 0, 0.36);
}
.item-price-promo-container {
padding: 5px;
width: 180px;
background-color: #fff;
height: 100%;
margin-left: 350px;
float: left;
}
<ol id="searchListContainer" class="search-list-container">
<li class="search-result">
<a id="hotel-id" class="search-result-item" href="#" target="_blank">
<section class="search-item-box">
<div class="media-box">
<figure class="media">
<img src="https://s15.postimg.org/7w2xbeufv/image.jpg" height="225"
width="225"
alt="1.jpg"/>
</figure>
</div>
<div class="item-price-promo-container">
<div class="item-review-container">
<ul class="item-star-rate">
<li class="item-star-rate-container review-item">
<strong class="item-star-rate-symbol">★</strong>
<strong class="item-star-rate-number">3.5</strong>
</li>
</ul>
</div>
</div>
</section>
</a>
</li>
Thank you!