Is there a way to have text wrap around a responsive image using the bootstrap grid layout? I am trying to avoid the use of media queries. This is essentially what I am going for :
I've tried a lot of different variations of rows and columns to get this to work. Perhaps I am being too stubborn and should just use media queries, but I thought maybe someone out there found a solution via bootstrap grid. Here is what I am currently working with.
<div class="container">
<div class="row">
<div class="col">
<h3>Lorem Ipsum</h3>
</div>
</div>
<div class="row">
<div class="col-md-5 col-lg-4">
<img class="img-fluid" src=https://www.clipartqueen.com/image-files/small-face-silhouette.png alt="Photo of me">
</div>
<div class="col-md-6 col-lg-7">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit ligula nec est aliquet ullamcorper. Suspendisse et semper lectus, vitae pellentesque tortor. Etiam bibendum leo ligula, id aliquam urna interdum ac. In egestas ornare mauris eget rutrum.
Pellentesque viverra suscipit nibh, vitae laoreet diam semper non. <br /><br /> Ut consequat scelerisque molestie. Vivamus vel lacus in ligula varius luctus non at diam. Suspendisse vitae tortor felis. Phasellus rutrum sapien ut lectus
pretium, ut ullamcorper enim dictum. Nam sagittis tempus dignissim.
</p>
</div>
</div>
</div>
You can simply wrap the content with simple float:left
Try this.
.row .col-md-5{float:left;}
.row{max-width:550px;}/*optional*/
<div class="container">
<div class="row">
<div class="col">
<h3>Lorem Ipsum</h3>
</div>
</div>
<div class="row">
<div class="col-md-5 col-lg-4">
<img class="img-fluid" src=https://www.clipartqueen.com/image-files/small-face-silhouette.png alt="Photo of me">
</div>
<div class="col-md-6 col-lg-7">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit ligula nec est aliquet ullamcorper. Suspendisse et semper lectus, vitae pellentesque tortor. Etiam bibendum leo ligula, id aliquam urna interdum ac. In egestas ornare mauris eget rutrum.
Pellentesque viverra suscipit nibh, vitae laoreet diam semper non. <br /><br /> Ut consequat scelerisque molestie. Vivamus vel lacus in ligula varius luctus non at diam. Suspendisse vitae tortor felis. Phasellus rutrum sapien ut lectus
pretium, ut ullamcorper enim dictum. Nam sagittis tempus dignissim.
</p>
</div>
</div>
</div>
PS: I set max-width just to make sure the content is wrapping.
You can make it single column instead of using two column. Bootstrap 4 default float-sm-left, pr-3, pb-3 class to align padding and floating the element. You can adjust the responsive by changing float-sm-left to float-md-left, float-lg-left, float-xl-left based on your requirement.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col">
<h3>Lorem Ipsum</h3>
</div>
</div>
<div class="row">
<div class="col-md-12">
<img class="img-fluid float-sm-left pr-3 pb-3" src=https://www.clipartqueen.com/image-files/small-face-silhouette.png alt="Photo of me">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit ligula nec est aliquet ullamcorper. Suspendisse et semper lectus, vitae pellentesque tortor. Etiam bibendum leo ligula, id aliquam urna interdum ac. In egestas ornare mauris eget rutrum.
Pellentesque viverra suscipit nibh, vitae laoreet diam semper non. Ut consequat scelerisque molestie. Vivamus vel lacus in ligula varius luctus non at diam. Suspendisse vitae tortor felis. Phasellus rutrum sapien ut lectus pretium, ut ullamcorper enim dictum. Nam sagittis tempus dignissim.<br>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit ligula nec est aliquet ullamcorper. Suspendisse et semper lectus, vitae pellentesque tortor. Etiam bibendum leo ligula, id aliquam urna interdum ac. In egestas ornare mauris eget rutrum.
</p>
</div>
</div>
</div>
<style type="text/css">
#media only screen and (max-width:480px) {
img {
display:block;
float:none;
margin:0 auto 20px !important;
}
}
</style>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body style="margin:0; background:#000;">
<div style="max-width:600px; margin:0 auto; background:#fff; overflow:hidden;">
<div style="Margin:20px;">
<img src="https://www.clipartqueen.com/image-files/small-face-silhouette.png" align="right" width="140" height="140" border="0" style="Margin:0 0 20px 20px; background:#E79851;"/>
<p style="Margin:0; font:16px/1.25 sans-serif; color:#4CB3E8; text-align:justify;">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta, aut eligendi dignissimos, illum eaque ut architecto quisquam! Odio, aliquam eligendi iste tempore beatae, deserunt! Officia temporibus at, debitis excepturi porro mollitia aspernatur labore unde dolores quae blanditiis dignissimos error aut iure magnam sed placeat impedit incidunt praesentium natus dolorum. Hic illum vitae iusto aspernatur tempora voluptatem id dolor reiciendis amet ea iste similique fuga, accusamus quibusdam, atque itaque quae sit dolorem asperiores facilis, fugit odio eveniet. Autem iusto nisi, minus sunt fuga quas sed expedita incidunt veniam nobis id ab. Blanditiis ullam laboriosam, quibusdam fugiat repellat labore nulla natus minima at, a veritatis nostrum dignissimos ipsa libero, voluptatem itaque!
</p>
</div>
</div>
</body>
</html>
You can use .float-left to make text wrap around the image:
.mw-25 {
max-width: 25%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col">
<h3>Lorem Ipsum</h3>
</div>
</div>
<div class="row">
<div class="col">
<div>
<img class="img float-left mw-25 border" src=https://www.clipartqueen.com/image-files/small-face-silhouette.png alt="Photo of me">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit ligula nec est aliquet ullamcorper.</p>
<p>Suspendisse et semper lectus, vitae pellentesque tortor. Etiam bibendum leo ligula, id aliquam urna interdum ac. In egestas ornare mauris eget rutrum.Pellentesque viverra suscipit nibh, vitae laoreet diam semper non.</p>
<p>Ut consequat scelerisque molestie. Vivamus vel lacus in ligula varius luctus non at diam. Suspendisse vitae tortor felis. Phasellus rutrum sapien ut lectus pretium, ut ullamcorper enim dictum. Nam sagittis tempus dignissim.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit ligula nec est aliquet ullamcorper.</p>
<p>Suspendisse et semper lectus, vitae pellentesque tortor. Etiam bibendum leo ligula, id aliquam urna interdum ac.</p>
</div>
</div>
</div>
</div>
Related
I have some Bootstrap card boxes that have various sizes of text that will be stored within each. I want to ensure that the box will retain the same height regardless of the amount. In that case, maybe only x amount of lines should be displayed which is fine, just want to make sure that the boxes themselves are a consistent height because this will mess up the whole page if they are not. These are bootstrap 3 boxes.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
<div class="container">
<div class="col-sm-4" v-for="(card, index) in cards">
<div v-if="canDisplay(index)" class="thumbnail">
<div class="caption text-center" onclick="">
<div class="position-relative">
<div v-html="getImage(card)">
</div>
</div>
<h4 id="thumbnail-label" v-html="getTextLinkUrl(card)">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" /> Testing
</h4>
<div class="thumbnail-description smaller" v-html="card.description"></div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="caption card-footer text-center">
<ul class="list-inline">
<li>
<button #click="edit(index)"><i
class="glyphicon glyphicon-pencil lighter"></i> Edit</button>
</li>
<li>
<button #click="remove(index)"><i
class="glyphicon glyphicon-trash lighter"></i> Remove</button>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-4" v-for="(card, index) in cards">
<div v-if="canDisplay(index)" class="thumbnail">
<div class="caption text-center" onclick="">
<div class="position-relative">
<div v-html="getImage(card)">
</div>
</div>
<h4 id="thumbnail-label" v-html="getTextLinkUrl(card)">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" /> Testing
</h4>
<div class="thumbnail-description smaller" v-html="card.description"></div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Dictum non consectetur a erat nam. Massa vitae tortor condimentum lacinia quis vel. Elementum eu facilisis sed odio
morbi. Tellus at urna condimentum mattis pellentesque id nibh. Et malesuada fames ac turpis egestas. Senectus et netus et malesuada. Massa enim nec dui nunc. Scelerisque in dictum non consectetur a. Vel quam elementum pulvinar etiam non quam lacus
suspendisse faucibus. Risus feugiat in ante metus dictum at tempor. Convallis convallis tellus id interdum velit. Id diam maecenas ultricies mi eget. Elementum curabitur vitae nunc sed velit dignissim sodales ut eu. Dignissim diam quis enim lobortis
scelerisque fermentum dui faucibus in. Metus aliquam eleifend mi in nulla. Accumsan lacus vel facilisis volutpat est velit egestas dui id. Nibh sit amet commodo nulla facilisi nullam vehicula. Sed id semper risus in hendrerit gravida rutrum quisque.
Eget felis eget nunc lobortis. Adipiscing enim eu turpis egestas pretium. Volutpat sed cras ornare arcu. Ac tortor dignissim convallis aenean. Risus nec feugiat in fermentum posuere. Turpis tincidunt id aliquet risus feugiat in ante metus. Vitae
nunc sed velit dignissim sodales ut. Tellus elementum sagittis vitae et leo duis ut diam. Nibh praesent tristique magna sit amet purus gravida quis blandit. Ornare suspendisse sed nisi lacus sed. Eu non diam phasellus vestibulum lorem. Amet nisl
suscipit adipiscing bibendum est ultricies integer quis auctor. Porta lorem mollis aliquam ut. Condimentum mattis pellentesque id nibh. Ipsum suspendisse ultrices gravida dictum. Consequat semper viverra nam libero justo laoreet sit. Nunc non
blandit massa enim nec dui nunc mattis enim. Ut porttitor leo a diam sollicitudin tempor id. Eget mauris pharetra et ultrices neque ornare aenean. Eu sem integer vitae justo eget magna. Vitae tempus quam pellentesque nec nam aliquam sem et. Aliquet
enim tortor at auctor. Nisl nisi scelerisque eu ultrices vitae auctor eu. Fames ac turpis egestas integer eget. Id velit ut tortor pretium viverra suspendisse potenti nullam ac. Dictum varius duis at consectetur lorem. Scelerisque felis imperdiet
proin fermentum leo. Id aliquet lectus proin nibh. Diam maecenas ultricies mi eget mauris pharetra. Vulputate enim nulla aliquet porttitor. Dictum sit amet justo donec.
</div>
<div class="caption card-footer text-center">
<ul class="list-inline">
<li>
<button #click="edit(index)"><i
class="glyphicon glyphicon-pencil lighter"></i> Edit</button>
</li>
<li>
<button #click="remove(index)"><i
class="glyphicon glyphicon-trash lighter"></i> Remove</button>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-4" v-for="(card, index) in cards">
<div v-if="canDisplay(index)" class="thumbnail">
<div class="caption text-center" onclick="">
<div class="position-relative">
<div v-html="getImage(card)">
</div>
</div>
<h4 id="thumbnail-label" v-html="getTextLinkUrl(card)">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" /> Testing
</h4>
<div class="thumbnail-description smaller" v-html="card.description"></div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="caption card-footer text-center">
<ul class="list-inline">
<li>
<button #click="edit(index)"><i
class="glyphicon glyphicon-pencil lighter"></i> Edit</button>
</li>
<li>
<button #click="remove(index)"><i
class="glyphicon glyphicon-trash lighter"></i> Remove</button>
</li>
</ul>
</div>
</div>
</div>
</div>
i remove your closing div and move your content inside the thumbnail-description. added a specific height and hide the overflow. hope this helps you.
.thumbnail {
height: 450px;
overflow: hidden;
}
.thumbnail-description {
max-height:300px;
overflow:hidden;
}
#media only screen and (max-width: 768px){
.thumbnail {
height:auto;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
<div class="container">
<div class="col-sm-4" v-for="(card, index) in cards">
<div v-if="canDisplay(index)" class="thumbnail">
<div class="caption text-center" onclick="">
<div class="position-relative">
<div v-html="getImage(card)">
</div>
</div>
<h4 id="thumbnail-label" v-html="getTextLinkUrl(card)">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" /> Testing
</h4>
<div class="thumbnail-description smaller" v-html="card.description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
<div class="caption card-footer text-center">
<ul class="list-inline">
<li>
<button #click="edit(index)"><i
class="glyphicon glyphicon-pencil lighter"></i> Edit</button>
</li>
<li>
<button #click="remove(index)"><i
class="glyphicon glyphicon-trash lighter"></i> Remove</button>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-4" v-for="(card, index) in cards">
<div v-if="canDisplay(index)" class="thumbnail">
<div class="caption text-center" onclick="">
<div class="position-relative">
<div v-html="getImage(card)">
</div>
</div>
<h4 id="thumbnail-label" v-html="getTextLinkUrl(card)">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" /> Testing
</h4>
<div class="thumbnail-description smaller" v-html="card.description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Dictum non consectetur a erat nam. Massa vitae tortor condimentum lacinia quis vel. Elementum eu facilisis sed odio morbi. Tellus at urna condimentum mattis pellentesque id nibh. Et malesuada fames ac turpis egestas. Senectus et netus et malesuada. Massa enim nec dui nunc. Scelerisque in dictum non consectetur a. Vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus. Risus feugiat in ante metus dictum at tempor. Convallis convallis tellus id interdum velit. Id diam maecenas ultricies mi eget. Elementum curabitur vitae nunc sed velit dignissim sodales ut eu. Dignissim diam quis enim lobortis scelerisque fermentum dui faucibus in. Metus aliquam eleifend mi in nulla.
Accumsan lacus vel facilisis volutpat est velit egestas dui id. Nibh sit amet commodo nulla facilisi nullam vehicula. Sed id semper risus in hendrerit gravida rutrum quisque. Eget felis eget nunc lobortis. Adipiscing enim eu turpis egestas pretium. Volutpat sed cras ornare arcu. Ac tortor dignissim convallis aenean. Risus nec feugiat in fermentum posuere. Turpis tincidunt id aliquet risus feugiat in ante metus. Vitae nunc sed velit dignissim sodales ut. Tellus elementum sagittis vitae et leo duis ut diam. Nibh praesent tristique magna sit amet purus gravida quis blandit. Ornare suspendisse sed nisi lacus sed. Eu non diam phasellus vestibulum lorem. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Porta lorem mollis aliquam ut. Condimentum mattis pellentesque id nibh. Ipsum suspendisse ultrices gravida dictum. Consequat semper viverra nam libero justo laoreet sit.
Nunc non blandit massa enim nec dui nunc mattis enim. Ut porttitor leo a diam sollicitudin tempor id. Eget mauris pharetra et ultrices neque ornare aenean. Eu sem integer vitae justo eget magna. Vitae tempus quam pellentesque nec nam aliquam sem et. Aliquet enim tortor at auctor. Nisl nisi scelerisque eu ultrices vitae auctor eu. Fames ac turpis egestas integer eget. Id velit ut tortor pretium viverra suspendisse potenti nullam ac. Dictum varius duis at consectetur lorem. Scelerisque felis imperdiet proin fermentum leo. Id aliquet lectus proin nibh. Diam maecenas ultricies mi eget mauris pharetra. Vulputate enim nulla aliquet porttitor. Dictum sit amet justo donec.
</div></div>
<div class="caption card-footer text-center">
<ul class="list-inline">
<li>
<button #click="edit(index)"><i
class="glyphicon glyphicon-pencil lighter"></i> Edit</button>
</li>
<li>
<button #click="remove(index)"><i
class="glyphicon glyphicon-trash lighter"></i> Remove</button>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-4" v-for="(card, index) in cards">
<div v-if="canDisplay(index)" class="thumbnail">
<div class="caption text-center" onclick="">
<div class="position-relative">
<div v-html="getImage(card)">
</div>
</div>
<h4 id="thumbnail-label" v-html="getTextLinkUrl(card)">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" /> Testing
</h4>
<div class="thumbnail-description smaller" v-html="card.description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="caption card-footer text-center">
<ul class="list-inline">
<li>
<button #click="edit(index)"><i
class="glyphicon glyphicon-pencil lighter"></i> Edit</button>
</li>
<li>
<button #click="remove(index)"><i
class="glyphicon glyphicon-trash lighter"></i> Remove</button>
</li>
</ul>
</div>
</div>
</div>
</div>
I faced with a problem with the vertical cards position in accordance with the design (image attached). Firstly I tried position it with the flexbox property but seems it's not the right way because it is just move element to the next line in a "natural flow" but I don't need such behaviour. The most closest solution was to set column-count: 2 property to the news__items class in parent container but I can't control the order in this case. I feel like display: grid can help here but can't figure out how to implement it yet. Note: images have the same height and width.
Here is the html and css markup:
.news__items {
column-count: 2;
}
<div class="news__items">
<div class="news__item">
<img src="../img/dummy-news-image.png" alt="news">
<div class="news__item-content">
<h2 class="news__primary-title">Lorem Ipsum</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed purus dolor. Phasellus velit libero, dapibus sed felis non, laoreet ornare risus. Morbi imperdiet maximus justo, nec porttitor ligula bibendum non. Aliquam erat volutpat. Sed feugiat
nulla quis mollis egestas. Duis blandit volutpat justo id imperdiet. Maecenas dapibus in quam vitae egestas.</p>
</div>
</div>
<div class="news__item">
<img src="../img/dummy-news-image.png" alt="news">
<div class="news__item-content">
<h3>Lorem ipsum</h3>
<h2 class="news__secondary-title">Lorem ipsum dolor
</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed purus dolor. Phasellus velit libero, dapibus sed felis non, laoreet ornare risus. Morbi imperdiet maximus justo, nec porttitor ligula bibendum non. Aliquam erat volutpat. Sed feugiat
nulla quis mollis egestas. Duis blandit volutpat justo id imperdiet. Maecenas dapibus in quam vitae egestas.</p>
</div>
</div>
<div class="news__item">
<img src="../img/dummy-news-image.png" alt="news">
<div class="news__item-content">
<h3>Lorem ipsum</h3>
<h2 class="news__secondary-title">Lorem ipsum dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed purus dolor. Phasellus velit libero, dapibus sed felis non, laoreet ornare risus. Morbi imperdiet maximus justo, nec porttitor ligula bibendum non. Aliquam erat volutpat. Sed feugiat
nulla quis mollis egestas. Duis blandit volutpat justo id imperdiet. Maecenas dapibus in quam vitae egestas.</p>
</div>
</div>
<div class="news__item">
<img src="../img/dummy-news-image.png" alt="news">
<div class="news__item-content">
<h3>Lorem ipsum</h3>
<h2 class="news__secondary-title">MFF in the News</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed purus dolor. Phasellus velit libero, dapibus sed felis non, laoreet ornare risus. Morbi imperdiet maximus justo, nec porttitor ligula bibendum non. Aliquam erat volutpat. Sed feugiat
nulla quis mollis egestas. Duis blandit volutpat justo id imperdiet. Maecenas dapibus in quam vitae egestas.</p>
</div>
</div>
<div class="news__item">
<img src="../img/dummy-news-image.png" alt="news">
<div class="news__item-content">
<h3>Lorem ipsum</h3>
<h2 class="news__secondary-title">Lorem Ipsum</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed purus dolor. Phasellus velit libero, dapibus sed felis non, laoreet ornare risus. Morbi imperdiet maximus justo, nec porttitor ligula bibendum non. Aliquam erat volutpat. Sed feugiat
nulla quis mollis egestas. Duis blandit volutpat justo id imperdiet. Maecenas dapibus in quam vitae egestas.</p>
</div>
</div>
</div>
What is the best approach to implement such grids?
Try this solution.
.news__items {
display: table;
}
.news__item {
width: 50%;
float: left;
}
I'm trying to achieve the following two column layout using Bootstrap 4:
My problem is, when I add content to the right column, it "pushes" the left one below, like this:
Here's my code so far:
<div class="row">
<div class="col-md-6">A</div>
<div class="col-md-6">C: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec at orci porta, suscipit felis at, facilisis dolor. Nulla turpis orci, congue ut quam eu, tincidunt pulvinar diam. Morbi iaculis aliquet libero nec sollicitudin. Praesent in erat in turpis aliquam rhoncus. Ut et augue iaculis, volutpat orci sed, auctor neque. Nam sit amet sollicitudin lorem, vel dapibus magna. Aliquam vestibulum eros enim, eget consequat sem dapibus nec.</div>
</div>
<div class="row">
<div class="col-md-6">B</div>
</div>
I'm not sure how to proceed next...
Technically, you should take 'B' part of the tag inside the 'A' tag and wrap both 'A' and 'B' with their own 'row' and 'col' tags.
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col">A</div>
</div>
<div class="row">
<div class="col">B</div>
</div>
</div>
<div class="col-md-6">C: Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Donec at orci porta, suscipit
felis at, facilisis dolor. Nulla turpis orci, congue ut quam eu, tincidunt pulvinar diam. Morbi iaculis
aliquet libero nec sollicitudin. Praesent in erat in turpis aliquam rhoncus. Ut et augue iaculis, volutpat
orci sed, auctor neque. Nam sit amet sollicitudin lorem, vel dapibus magna. Aliquam vestibulum eros enim,
eget consequat sem dapibus nec.
</div>
</div>
You can achieve the structure you are asking for as below. You were just mistaking while placing row and columns.
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-12">
A
</div>
<div class="col-md-12">
B
</div>
</div>
</div>
<div class="col-md-6">C: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec at orci porta, suscipit felis at, facilisis dolor. Nulla turpis orci, congue ut quam eu, tincidunt pulvinar diam. Morbi iaculis aliquet libero nec sollicitudin. Praesent in erat in turpis aliquam rhoncus. Ut et augue iaculis, volutpat orci sed, auctor neque. Nam sit amet sollicitudin lorem, vel dapibus magna. Aliquam vestibulum eros enim, eget consequat sem dapibus nec.</div>
</div>
Normally when you have a block of text you can just float the image left or right to wrap the text around it, but in flexbox floats do not work and I am struggling to find a solution.
Bootstrap 4 is going to use flexbox for their new grid system but this might be a deal breaker if you can't have a block of text in a column and also have text wrap around an image.
Firstly, flexbox is not a grid system nor is it intended to replace one.
Indeed, Bootstrap 4 still has pretty much the same grid system but BS4 now adds the ability to use some of the benefits of flexbox in addition.
As for floats...yes, if you set the parent element to display:flex the immediate children (flex-children or flex-items) cannot be floated.
BUT since the display value is not inherited, your floated contents will still wrap fine.
img {
float: left;
margin-right: 1em;
}
.col-md-6,
.col-sm-6 {
background: pink;
}
.row {
display: flex;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-6">
<img src="http://www.fillmurray.com/40/40" alt="" />
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque explicabo aspernatur delectus voluptate, nesciunt quibusdam ab reprehenderit, non et temporibus. Aut commodi, voluptates nulla deleniti pariatur vitae vel eos sit asperiores aliquid,
molestiae recusandae placeat corporis earum assumenda dolorem! Earum necessitatibus tempora enim nisi officiis in. Ducimus illo placeat eveniet.</p>
</div>
<div class="col-md-6 col-sm-6">
<img src="http://www.fillmurray.com/40/40" alt="" />
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque explicabo aspernatur delectus voluptate, nesciunt quibusdam ab reprehenderit, non et temporibus. Aut commodi, voluptates nulla deleniti pariatur vitae vel eos sit asperiores aliquid,
molestiae recusandae placeat corporis earum assumenda dolorem! Earum necessitatibus tempora enim nisi officiis in. Ducimus illo placeat eveniet.</p>
</div>
</div>
</div>
Not a full solution like float, but we can use + in CSS to wrap image's next tag.
.container {
display: flex;
flex-wrap: wrap;
width: 100%;
}
h3 {
width: 100%;
}
.page-pic {
margin: 0 20px 0 0;
max-width: 200px;
}
.container .page-pic+p {
flex: 1;
position: relative;
top: -20px
}
<div class="container">
<h3>Some Title</h3>
<img src="https://picsum.photos/id/1073/200/200" class="page-pic">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu ornare quam. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus molestie sodales ante a suscipit. Proin sed diam nisi. Nunc lobortis et nulla auctor varius. Cras dignissim,
metus sit amet aliquam posuere, ante magna pharetra justo, at mattis turpis purus non nibh. Quisque congue mauris id ligula fringilla fermentum. Morbi laoreet nec nulla non rhoncus. Etiam vitae tellus eget nunc finibus eleifend vel non ante. Nunc
odio odio, fermentum ac hendrerit non, consequat nec felis. </p>
<h3>Another Title</h3>
<p>Another Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu ornare quam. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus molestie sodales ante a suscipit. Proin sed diam nisi. Nunc lobortis et nulla auctor varius.
Cras dignissim, metus sit amet aliquam posuere, ante magna pharetra justo, at mattis turpis purus non nibh. Quisque congue mauris id ligula fringilla fermentum. Morbi laoreet nec nulla non rhoncus. Etiam vitae tellus eget nunc finibus eleifend vel
non ante. Nunc odio odio, fermentum ac hendrerit non, consequat nec felis. </p>
</div>
How to create a layout using bootstrap similar on the image below? In web the first column indicate as their label (Developer, Project Overview, etc) and the succeeding columns is their description on different items. On mobile must be vertically align together with their content. Just want a started code using bootstrap 3 on how to make a layout just like on the image and I will make the rest.
This is my sample code but when it view on mobile is different on what I've wanted . I want a design just like on the image above.
<div class="row bg-highlight">
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12 first">
<h4>Project</h4>
</div>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<h4>BRIO TOWER</h4>
<img src="http://placehold.it/900x600" alt="img" title="U-Travel Services Inc" class="img-responsive thumbnail" >
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<h4>BRIO TOWER</h4>
<img src="http://placehold.it/900x600" alt="img" title="U-Travel Services Inc" class="img-responsive thumbnail" >
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<h4>BRIO TOWER</h4>
<img src="http://placehold.it/900x600" alt="img" title="U-Travel Services Inc" class="img-responsive thumbnail" >
</div>
</div>
</div>
</div>
<div class="row bg-light-gray">
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12 first">
<h5>Developer</h5>
</div>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<p>DMCI Homes</p>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<p>SMDC</p>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<p>AVIDA LAND</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12 first">
<h5>Project Overview</h5>
</div>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</div>
</div>
This is a good start for the basic markup you should use. If you are needing those labels on the left to line up with each block of text, it may need to be revised.
HTML
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1>Compare Property</h1>
<hr>
<p>Use this document as a way to quickly start any new project. All you get is this text and a mostly barebones HTML document.</p>
</div>
</div>
<div class="row with-images">
<div class="col-sm-3 hidden-xs">
<p class="descriptions">X</p>
<p class="descriptions">Developer</p>
<p class="descriptions">Overview</p>
<p class="descriptions">Location</p>
</div>
<div class="col-sm-3">
<div class="image-wrap">
<img src="http://placehold.it/900x600">
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam imperdiet lectus a facilisis iaculis. Morbi nec velit pharetra, commodo velit et, varius elit. Mauris at tincidunt nisl, quis sollicitudin tellus. In ac hendrerit leo, in congue dolor. Curabitur nec elit vitae ligula semper eleifend. Suspendisse molestie dignissim feugiat. Pellentesque consectetur nulla urna, sagittis rutrum eros tristique ac. Donec commodo ultrices justo, quis tempor erat aliquet id. </p>
<p>Etiam non est semper, cursus arcu quis, finibus neque. Aliquam blandit ante mollis urna accumsan, ullamcorper malesuada nulla fringilla. Suspendisse potenti. Nullam vehicula mauris id nulla interdum pretium. Morbi sollicitudin cursus quam, tincidunt ultrices massa faucibus et. Sed cursus sollicitudin erat, vitae eleifend lectus cursus sed. Nam tempor libero vitae nibh bibendum laoreet. Maecenas dictum ex nec urna rutrum laoreet. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Pellentesque congue ultricies ex, ac porttitor urna mollis tristique. Donec condimentum accumsan lacus sed dictum. Pellentesque sagittis accumsan congue.</p>
</div>
<div class="col-sm-3">
<div class="image-wrap">
<img src="http://placehold.it/900x600">
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam imperdiet lectus a facilisis iaculis. Morbi nec velit pharetra, commodo velit et, varius elit. Mauris at tincidunt nisl, quis sollicitudin tellus. In ac hendrerit leo, in congue dolor. Curabitur nec elit vitae ligula semper eleifend. Suspendisse molestie dignissim feugiat. Pellentesque consectetur nulla urna, sagittis rutrum eros tristique ac. Donec commodo ultrices justo, quis tempor erat aliquet id. </p>
<p>Etiam non est semper, cursus arcu quis, finibus neque. Aliquam blandit ante mollis urna accumsan, ullamcorper malesuada nulla fringilla. Suspendisse potenti. Nullam vehicula mauris id nulla interdum pretium. Morbi sollicitudin cursus quam, tincidunt ultrices massa faucibus et. Sed cursus sollicitudin erat, vitae eleifend lectus cursus sed. Nam tempor libero vitae nibh bibendum laoreet. Maecenas dictum ex nec urna rutrum laoreet. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Pellentesque congue ultricies ex, ac porttitor urna mollis tristique. Donec condimentum accumsan lacus sed dictum. Pellentesque sagittis accumsan congue.</p>
</div>
<div class="col-sm-3">
<div class="image-wrap">
<img src="http://placehold.it/900x600">
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam imperdiet lectus a facilisis iaculis. Morbi nec velit pharetra, commodo velit et, varius elit. Mauris at tincidunt nisl, quis sollicitudin tellus. In ac hendrerit leo, in congue dolor. Curabitur nec elit vitae ligula semper eleifend. Suspendisse molestie dignissim feugiat. Pellentesque consectetur nulla urna, sagittis rutrum eros tristique ac. Donec commodo ultrices justo, quis tempor erat aliquet id. </p>
<p>Etiam non est semper, cursus arcu quis, finibus neque. Aliquam blandit ante mollis urna accumsan, ullamcorper malesuada nulla fringilla. Suspendisse potenti. Nullam vehicula mauris id nulla interdum pretium. Morbi sollicitudin cursus quam, tincidunt ultrices massa faucibus et. Sed cursus sollicitudin erat, vitae eleifend lectus cursus sed. Nam tempor libero vitae nibh bibendum laoreet. Maecenas dictum ex nec urna rutrum laoreet. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Pellentesque congue ultricies ex, ac porttitor urna mollis tristique. Donec condimentum accumsan lacus sed dictum. Pellentesque sagittis accumsan congue.</p>
</div>
</div>
</div><!-- /.container -->
CSS
.with-images img {
max-width:100%;
height:auto;
}
.image-wrap {
margin-bottom:15px;
}
Example on Bootply