I'm creating a "Why Choose Us" splash page and I want to create tables with an image on one side and a reason on the other. I need the image to vertically align in the center.
So far I've tried making another table inside the table, and vertically aligning the image with 'vertical-align: middle' via a table cell wrapped around it.
<section class="reason">
<div class="content">
<div class="float-left table">
<div class="table-cell">
<img class="thumbnail" src="https://1eican1u2cuw7g1kw7btt2xy-wpengine.netdna-ssl.com/wp-content/uploads/personal-attention-vamospanish-85x85.png">
</div>
</div>
<div class="float-right">
<h3>
Lorem Ipsum Dolor Sit Amet
</h3>
<p class="appeal">Lorem ipsum dolor sit amet, consectetur adipisicing 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>
</section>
<style>
.reason {
padding: 100px;
background-color: #fff;
}
.content {
display: table;
clear: both;
max-width: 935px;
margin: 0 auto;
}
.float-left {
float: left;
width: 50%;
}
.float-right {
float: right;
width: 50%;
}
.table {
display: table;
}
.table-cell {
display: table-cell;
vertical-align: middle;
}
.thumbnail {
display: block;
margin: 0 auto;
}
</style>
Here's a codepen outlining the problem: https://codepen.io/AlecAcres/pen/NVMRoY
May be a style to <td>?
<style>
td img {
vertical-align: top;
}
</style>
I have changed the code (basically used flex instead of table) -:
Working demo here
HTML
<section class="reason">
<div class="content">
<div class="float-left">
<div class="table-cell">
<img class="thumbnail" src="https://1eican1u2cuw7g1kw7btt2xy-wpengine.netdna-ssl.com/wp-content/uploads/personal-attention-vamospanish-85x85.png">
</div>
</div>
<div class="float-right">
<h3>
Lorem Ipsum Dolor Sit Amet
</h3>
<p class="appeal">Lorem ipsum dolor sit amet, consectetur adipisicing 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>
</section>
CSS
.reason {
padding: 100px;
background-color: #fff;
}
.content {
display: flex;
justify-content: center;
max-width: 935px;
margin: 0 auto;
}
.float-left {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
}
.float-right {
flex: 1
}
.table-cell {
display: table-cell;
vertical-align: middle;
}
.thumbnail {
display: block;
margin: 0 auto;
}
.flex-container {
display: flex;
}
.flex-image {
display: flex;
flex-flow: column wrap;
justify-content: space-evenly;
}
<div class="flex-container">
<div class="flex-image">
<img
src="https://1eican1u2cuw7g1kw7btt2xy-wpengine.netdna-ssl.com/wp-content/uploads/personal-attention-vamospanish-85x85.png">
</div>
<div class="flex-content">
<h3>
Lorem Ipsum Dolor Sit Amet
</h3>
<p class="appeal">Lorem ipsum dolor sit amet, consectetur adipisicing 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>
Here is a more modern approach using FlexBox!
Demo:
https://codepen.io/anon/pen/WBJoxY
HTML:
<section class="reason">
<div class="content">
<div class="thumbnail">
<img src="https://1eican1u2cuw7g1kw7btt2xy-wpengine.netdna-ssl.com/wp-content/uploads/personal-attention-vamospanish-85x85.png">
</div>
<div class="text">
<h3>
Lorem Ipsum Dolor Sit Amet
</h3>
<p class="appeal">
Lorem ipsum dolor sit amet, consectetur adipisicing 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>
</section>
CSS:
.reason {
padding: 100px;
background-color: #fff;
}
.content {
display: flex;
flex-direction: row;
max-width: 935px;
margin: 0 auto;
}
.text {
max-width: 50%;
}
.thumbnail {
display: flex;
margin: 0 auto;
justify-content: center;
align-items: center;
}
Related
I want these below contents to have 50% width equally on PC's and 100% in mobile devices.
<style>
.container {
display: flex;
flex-wrap: wrap;
}
.box-left {
width: 100%
}
.box-right {
width: 100%
}
</style>
<div class="container">
<div class="box-left">
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>
<img class="box-right" src="https://i.imgur.com/gawfygm.png" />
</div>
Expand or Shrink the view to check if its working.
.container {
display: flex;
flex-direction: column;
}
.box-left {
width: 100%;
font-size: 1rem;
font-family: 'Work Sans', sans-serif;
line-height: 1.5;
padding: 1rem;
}
.box-right {
margin: 0 auto;
width: 100%;
height: auto;
}
#media(min-width:576px) {
.container {
flex-direction: row;
}
.box-left {
width: 50%;
background: lightblue;
}
.box-right {
width: 50%;
background: lightcoral;
}
}
<div class="container">
<div class="box-left">
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>
<img class="box-right" src="https://i.imgur.com/gawfygm.png" />
</div>
I have a web-page, which has a body that expands over time (by user clicks and such), that I want to be centered (vertically).
I also want it to be scroll-able when the content exceeds the page's height (when it overflows), but then it has to be aligned to the top of the page.
I want it to behave like this, and I want to achieve it with flexbox:
Any ideas?
If possible define new tags with class attributes "container" and "box"
window -> .container
body -> .box
* {
margin: 0;
padding: 0;
}
.container {
display: grid;
align-items: center;
height: 100vh;
overflow: scroll;
}
.box {
background-color: yellow;
}
<div class="container">
<div class="box">
this is box
</div>
</div>
here is one for the flex box
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
}
.container {
position: relative;
background: darkcyan;
width: 60%;
padding: 5%;
display: flex;
justify-content: space-around;
align-items: center;
}
.content {
background: cyan;
width: 80%;
overflow-y: scroll;
max-height: 400px;
text-align: center;
}
<div class="container">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Lorem ipsum dolor sit amet, consectetur adipisicing 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>
I have 2 contents, the first one is blue section and the second one is purple section.
I add position absolute in the second section since I want to make the content share background, half with blue section and purple section.
My question, if I add more text on the first section, the text for the first section is hidden behind the second section.
Is there a way to make the first section flexible?
So whenever I add more text, the second section will not hide the text.
.commercial-wrapper {
display: flex;
position: relative;
bottom: 320px;
}
.commercial-white {
background-color: #f1f1f4;
width: 340px;
height: 460px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-bottom: 15px solid #005da0;
margin: 10px;
}
.commercial-blue {
position: absolute;
background-color: #005da0;
color: #ffffff;
width: 340px;
height: 473px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 10px;
border: 2px solid #ffffff;
visibility: hidden;
}
.open.commercial-blue {
visibility: visible;
}
.commercial-flip {
padding: 20px;
pointer-events: none;
}
.main-wrapper {
display: flex;
flex-direction: column;
background-color: purple;
justify-content: center;
}
.commercial-wrapper-text {
text-align: center;
background-color: #215cad;
color: #ffffff;
padding: 20px 0;
height: 500px;
}
.commercial-main-wrapper-flip {
background-color: purple;
position: relative;
height: 200px;
}
.commercial-wrapper-flip {
display: flex;
justify-content: center;
position: relative;
flex-wrap: wrap;
}
#industry-block {
background-color: #dce5ee;
}
.commit-industry {
border: 1px solid purple;
text-align: center;
position: relative;
}
<div class="commercial-solution-wrapper">
<div class="commercial-wrapper-text">
<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.<br />
<br />
<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.<br />
<br />
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.<br />
<br />
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 class="commercial-main-wrapper-flip">
<div class="commercial-wrapper-flip">
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
</div>
</div>
EDIT: add an image for expected result
Because you are adding position: absolute you are taking that element out of document flow - so the text won't ever interact with the content below (hence the hiding).
One way to do it is to add a linear gradient to the second wrapper. So you are essentially "faking" the overlap.
The important part:
.commercial-main-wrapper-flip {
background: linear-gradient(0deg, rgba(191, 0, 254, 1) 55%, rgba(33, 92, 173, 1) 55%);
position: relative;
}
.commercial-wrapper {
display: flex;
position: relative;
}
.commercial-white {
background-color: #f1f1f4;
width: 340px;
height: 460px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-bottom: 15px solid #005da0;
margin: 10px;
}
.commercial-blue {
position: relative;
background-color: #005da0;
color: #ffffff;
width: 340px;
height: 473px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 10px;
border: 2px solid #ffffff;
visibility: hidden;
}
.open.commercial-blue {
visibility: visible;
}
.commercial-flip {
padding: 20px;
pointer-events: none;
}
.main-wrapper {
display: flex;
flex-direction: column;
background-color: purple;
justify-content: center;
}
.commercial-wrapper-text {
text-align: center;
background-color: #215cad;
color: #ffffff;
padding: 20px 0;
}
.commercial-main-wrapper-flip {
background: linear-gradient(0deg, rgba(191, 0, 254, 1) 55%, rgba(33, 92, 173, 1) 55%);
position: relative;
}
.commercial-wrapper-flip {
display: flex;
justify-content: center;
position: relative;
flex-wrap: wrap;
}
<div class="commercial-solution-wrapper">
<div class="commercial-wrapper-text">
<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.<br />
<br />
<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.<br />
<br /> 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.<br />
<br /> 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 class="commercial-main-wrapper-flip">
<div class="commercial-wrapper-flip">
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
<div class="commercial-wrapper">
<div class="commercial-white">
<div class="commercial-flip">
<h3>Lorem ipsum</h3>
</div>
</div>
</div>
</div>
</div>
This is my html code
<div class="longtext">
<div class="image">
<img src="https://c1.staticflickr.com/8/7610/17149522281_3b6ae4c948_b.jpg" alt="">
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing 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="buy">
$ 3053
</div>
</div>
I would like to achieve to display all content inline, something like this.
Image have defined dimensions, .text and .buy width is unknown. .buy must be always displayed whole and at single line. .text must be displayed on one line as well but its not necessary to display whole text.
Here is my css yet
.longtext {
border: 1px solid red;
overflow: hidden;
}
.longtext > * {
float: left;
}
.longtext img {
height: 60px;
width: 60px;
}
.buy {
float: right;
border: 1px solid blue;
}
.text {
border: 1px solid black;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Codepen
I would use flex on the parent and align-items to align them vertically. Add flex-grow: 1 to .text (or flex: 1 0 0; for short) so it fills the available space, and add the overflow/ellipsis to the p. Then you can remove the floats from everything else. Also added white-space: nowrap to the .buy element so the space between the $ and numbers won't break.
.longtext {
border: 1px solid red;
display: flex;
align-items: center;
}
.longtext img {
height: 60px;
width: 60px;
vertical-align: top;
}
.buy {
border: 1px solid blue;
}
.text {
border: 1px solid black;
overflow: hidden;
}
.text p {
text-overflow: ellipsis;
overflow: hidden;
}
.buy, .text {
white-space: nowrap;
}
<div class="longtext">
<div class="image">
<img src="https://c1.staticflickr.com/8/7610/17149522281_3b6ae4c948_b.jpg" alt="">
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing 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="buy">
$ 3053
</div>
</div>
.longtext {
border: 1px solid red;
display: flex;
}
.longtext img {
height: 60px;
width: 60px;
}
.longtext div{
vertical-align: top;
}
.buy {
border: 1px solid blue;
}
.text {
border: 1px solid black;
overflow: hidden;
}
.text p {
text-overflow: ellipsis;
overflow: hidden;
}
.buy, .text {
white-space: nowrap;
}
<div class="longtext">
<div class="image">
<img src="https://c1.staticflickr.com/8/7610/17149522281_3b6ae4c948_b.jpg" alt="">
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing 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="buy">
$ 30530000
</div>
</div>
<div class="longtext">
<div class="image">
<img src="https://c1.staticflickr.com/8/7610/17149522281_3b6ae4c948_b.jpg" alt="">
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing 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="buy">
$ 30500
</div>
</div>
I want to align an image beside a text. But for some reason, all I trye makes the text either wrap around the image or be placed below it. This is my current code:
.cc-testimonial-quote {
font-style: italic;
font-weight: 600;
max-width: 700px;
display: block;
margin: 0px auto;
img {
height: 16px;
margin-right: 20px;
}
div {
display: inline-block;
height: 100%;
}
}
<div class="container box">
<div class="row">
<div class="cc-testimonial-quote">
<div><img src="/src/to/img.jpg"></div>
<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>
</div>
</div>
At the moment, the text is place below the image. I have also tried
div tag gets float:left - places text below image
replacing div with span - wraps text around image
replacing div with span and adding display:inline-block; to spans - places text below image
removing div tag around image and text - wraps text around image
float:left; on only div with image - wraps text around image
float:left; on div with image and float:right; on div with text - places text below image
adding display: inline-block; to img tag - places text below image
Note that the container, box and row classes comes from Bootstrap. Can that affect it somehow?
Searching has not found me a solution other than the ones I've tried before, but I might have overlooked some solution posted here before.
You could use display: table-cell on divs inside cc-testimonial-quote DEMO
.cc-testimonial-quote > div {
display: table-cell;
}
If you are using bootstrap why don't you let it set the layout for you without additional css?
<div class="container box">
<div class="row">
<div class="col-sm-4">
<img class="img-responsive" src="/src/to/img.jpg">
</div>
<div class="col-sm-8">
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>
Here is your updated code : https://jsfiddle.net/06c3av7r/1/
You have to make some changes in DIV elements.
.cc-testimonial-quote {
font-style: italic;
font-weight: 600;
max-width: 700px;
display: block;
margin: 0px auto;
img {
height: 16px;
margin-right: 20px;
}
div {
display: inline-block;
height: 100%;
}
}
<div class="container box">
<div class="row">
<div class="cc-testimonial-quote">
<div><img src="/src/to/img.jpg">
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>
</div>
Try the solution below. I assigned display: flex to the container and removed some stuff.
.cc-testimonial-quote {
display: flex;
font-style: italic;
font-weight: 600;
max-width: 700px;
}
img {
height: 16px;
margin-right: 20px;
}
<div class="container box">
<div class="row">
<div class="cc-testimonial-quote">
<div>
<img src="/src/to/img.jpg" />
</div>
<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>
</div>
</div>
You want to do this effect:
.cc-testimonial-quote {
font-style: italic;
font-weight: 600;
max-width: 700px;
display: block;
margin: 0px auto;
}
.cc-testimonial-quote > img {
float: left;
height: 26px;
margin: 0 10px 10px 0;
}
<div class="container box">
<div class="row">
<div class="cc-testimonial-quote">
<img src="http://www.politicalmetaphors.com/wp-content/uploads/2015/04/blog-shapes-square-windows.jpg">
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>
Or this effect:
.cc-testimonial-quote {
font-style: italic;
font-weight: 600;
max-width: 700px;
display: block;
margin: 0px auto;
}
.cc-testimonial-quote > .image-wrapper {
float: left;
}
.cc-testimonial-quote > .image-wrapper > img {
height: 26px;
margin: 0 10px 10px 0;
}
.cc-testimonial-quote > .text-wrapper {
overflow: auto;
}
<div class="container box">
<div class="row">
<div class="cc-testimonial-quote">
<div class="image-wrapper">
<img src="http://www.politicalmetaphors.com/wp-content/uploads/2015/04/blog-shapes-square-windows.jpg">
</div>
<div class="text-wrapper">
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>
</div>
Choose one in a comment and I'll explain it in detail!