I am trying to make a list of images and descriptions that are in sets of threes at larger widths, and go to sets of twos at smaller widths. But when I break down it gets very messed up, and I don't know what to do to make it break down into clean one-half columns. Thanks in advance for your help!
div.thirds {
padding-bottom: 20px;
padding: 50px;
text-align: center;
font-family: Gudea;
}
div.button1 {
width:90px;
height:40px;
margin-left: 38%;
}
div.one-third {
width: 30%;
float: left;
margin-right: 5%;
text-align: center;
font-family: Gudea;
}
div.button2 {
width:90px;
height:40px;
margin-left: 38%;
}
div.one-third-last {
margin: 0;
text-align: center;
font-family: Gudea;
}
div.button3 {
width:90px;
height:40px;
margin-left: 38%;
}
#media (maxwidth:900px;)
div.one-third {
width: 47.5%;
}
div.one-third-second {
margin: 0;
}
div.one-third-last {
clear: both;
float: none;
width: auto;
padding: 20px 0 0 0;
}
div.one-third {
width: 47.5%;
}
div.one-third-second {
margin: 0;
}
div.one-third-last {
clear: both;
float: none;
width: auto;
padding: 20px 0 0 0;
}
<div class="thirds clearfix">
<!-- one-third -->
<div class="one-third mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird on a fence" />
<h2>The Trainer</h2>
<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 class="button1">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-second mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird eating" />
<h2>Lessons</h2>
<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 class="button2">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-fourth mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A cat" />
<h2>Training</h2>
<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 class="button3">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
</div><!--/thirds-->
<!-- thirds -->
<div class="thirds clearfix">
<!-- one-third -->
<div class="one-third mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird on a fence" />
<h2>The Trainer</h2>
<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 class="button1">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-second mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird eating" />
<h2>Lessons</h2>
<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 class="button2">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-last mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A cat" />
<h2>Training</h2>
<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 class="button3">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
</div>
I'm sure your problem is around mixing percentage and fixed values. Try and think in terms of having 100% to play with. If you for example have a width of 48% with a fixed margin of say 100px, what happens if 100px is bigger than the 2% you have left to play with. Problems. That's what.
Are you allowed to use CSS Flex? If it fits in your minimum level of required CSS browser support, it could really save you a lot of the headache you're currently dealing with trying to manage floats.
CSS
.flex {
display: flex;
}
.wrap {
flex-wrap: wrap;
}
.item {
width: 33%;
}
#media (max-width: 900px) {
.item {
width: 50%;
}
}
HTML
<div class="flex wrap">
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
<div class="item">Item 4</div>
<div class="item">Item 5</div>
<div class="item">Item 6</div>
</div>
You can expand the example to include additional markup inside each .item class. I provide a larger example here - JSFiddle
bootstrap is the way to go - the following will display 2 rows of 3 divs on a medium to large viewport. 3 rows of 2 divs on a small viewport. Note that there is a col-lg class as well if you want to have another style for large screens and a col-sm class if you want a class between mobile size (xs) and small screen (sm), also I have not inserted the OP code into the divs - I just wanted to demonstrate the point:
click the full screen link in the following snippet to see the div's change position depending on the width of the viewport. I also added a border to each and centered the text - just for demonstration purposes.
.container div{
text-align:center;
border:solid 1px #ddd}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
</div>
Related
The problem is I have to make div with aside class scrollable, but the right side with picture not.
For now it is not scrollable because position is not fixed (screenshot):
but if I add position:fixed; to aside class - it will be scrollable, but the right side will move left, which is bad.
body {
background-color: #2e7744;
overflow:hidden;
}
.aside {
height: 100%;
overflow-y: auto;
position:fixed;
}
<body>
<div class="container-fluid">
<div class="row">
<div class="aside col-lg-3">
<nav class="menu background sidebar card mb-4">
<ul class="nav flex-column">
<li class="nav-item">
<span class="nav-link" style="background-color: #71a4ff66">
<b class="header">Cat 1</b>
</span>
<ul class="background">
<li class="nav-item hover">
<a class="poster-link " href="/poster/index.php?pid=3">
<div>Pic 1</div>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<span class="nav-link">
<b class="header">Cat 2</b>
</span>
<ul class="background">
<li class="nav-item hover">
<a class="poster-link " href="/poster/index.php?pid=1">
<div>Text 1</div>
</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<div class="col-sm-12 col-lg-12 col-xl-4 mt-4">
<div class="row">
<div class="col-sm-12">
Picture with text
</div>
</div>
</div>
</div>
</div>
</body>
Is there an option to solve this problem quick?
This HTML structure works perfectly on mobile, I have to preserver it somehow.
Any ideas?
What you need to do is encapsulate the menu pane in a div and then assign position fixed in menu pane class with respect to its parent div.
Below is the code to prove the same:
* {
margin: 0px;
padding: 0px;
font-family: 'arial';
}
.container-fluid {
width: 100%;
display: grid;
grid-template-columns: 30% 70%;
}
.left_pane {
background: black;
display: flex;
justify-content: center;
align-items: center;
}
.menu_pane {
top: 0;
left: 0;
position: fixed;
display: flex;
flex-direction: column;
overflow-y: scroll;
height: 100vh;
width: 30%;
}
.menu_pane a {
padding: 25px 20px;
background: black;
color: white;
border: 1px solid black;
text-align: center;
font-size: 50px;
text-decoration: none;
transition: 0.4s;
}
.menu_pane a:hover {
background: white;
color: black;
}
.right_pane {
display: flex;
flex-direction: column;
padding: 20px;
}
.content_pane {
padding: 20px 10px;
display: flex;
flex-direction: column;
}
.content_pane h1 {
font-size: 50px;
text-transform: uppercase;
padding-bottom: 20px;
}
.content_pane p {
font-size: 20px;
width: 70%;
}
<div class="container-fluid">
<div class="left_pane">
<div class="menu_pane">
Button 1
Button 2
Button 3
Button 4
Button 5
Button 6
Button 7
Button 8
Button 9
Button 10
Button 11
Button 12
</div>
</div>
<div class="right_pane">
<div class="content_pane">
<h1>Heading</h1>
<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="content_pane">
<h1>Heading</h1>
<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="content_pane">
<h1>Heading</h1>
<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="content_pane">
<h1>Heading</h1>
<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="content_pane">
<h1>Heading</h1>
<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="content_pane">
<h1>Heading</h1>
<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>
</div>
With "bootstrap": "^4.3.1"
I try to make image aligned left and content which floats image from the right and would be visible below of the image ( without empty space under image ).
I works ok to in class single_forum_image_left_aligned to leave float: left; property:
.single_forum_image_left_aligned_wrapper {
border: 3px dotted red;
align-items:start;
}
.single_forum_image_left_aligned {
display: flex;
justify-self: flex-start;
justify-content: flex-start;
/*float: left;*/
padding: 2px;
margin: 5px;
max-width: 460px;
max-height: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="single_forum_image_left_aligned_wrapper">
<a class="a_link" >
<img class="single_forum_image_left_aligned" src="imagepath/general-business.jpeg?dt=1606807690"
alt="Mount Everest is found in which mountain range?">
</a>
<p class="card-text " style="align-items:start">
Lorem <strong>ipsum dolor sit</strong> amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis <strong>nostrud exercitation</strong> 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>
But that does not seems good decision for me.
Are there some better solution ?
You don't need to write single line of code of this type of view in Bootstrap-v4+
In Bootstrap-v4 there is predefined class .float-left for float: left; property.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container py-3">
<div class="row">
<div class="col-sm-12">
<div class="d-block clearfix bg-light p-3 shadow">
<a class="float-left mr-3">
<img src="https://placeimg.com/150/150/animals" class="rounded">
</a>
<p>
Lorem <strong>ipsum dolor sit</strong> amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis <strong>nostrud exercitation</strong> 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>
Currently I have this:
When I resize this container, the text is out of my box.
How my card is made:
<div class="container selfsizing nobackground">
<div class="row selfsizing">
<div class="col-sm nopadding">
<div class="d-flex justify-content-between">
<span style="font-weight: bold;">{{dashboard_card['card_title']}}</span>
<form method="post">
<button name="deleteCard" class="delete" type="submit" value="{{dashboard_card['id']}}">x</button>
</form>
</div>
<div class="d-flex justify-content-between card-text">
<span style="font-weight: bold;">{{dashboard_card['card_text']}}</span>
</div>
</div>
</div>
</div>
How can I hide the text, when I resize the div vertically?
You can use overflow:hidden; css property on the container.
.container{
overflow:hidden;
}
example
.container {
width: 300px;
background: orange;
padding: 10px;
margin: 20px auto;
}
.container.overflow-h {
width: 300px;
height: 50px;
background: orange;
overflow: hidden;
padding: 10px;
margin: 20px auto;
}
<div class="container overflow-h">
<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="container">
<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>
Hope this helps!
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!
I'm currently building a site which is one of those tall pages broken up in to horizontal panels for each different section.
Some of the horizontal panels are fixed-width centred in the middle (see 1,2,3,5 in diagram) and some are full-width (see 4 in diagram). For the fixed-width I'm using a ".container" class and that's easy enough and working fine. For the full-width panels I'm using ".container-fluid".
Now the problem I'm facing is as follows (see image for reference.)
So panel 4 is full width and consists of 2 columns. The textual content is between B & C, and C & D, however there is 2 background images that span A to C and C to E and I can't figure out how to do that.
I've tried to split it in to 2 columns and then have a fixed width section in the middle but can't get it working. This is where I'm currently at:
<div class="container-fluid">
<div class="col-sm-6">
<img src="" />
<div class="container">
</div>
</div>
<div class="col-sm-6">
<img src="" />
<div class="container">
</div>
</div>
</div>
Any advice greatly appreciated.
EDIT: Added two-column split for container-fluid.
From what I understood from the image shown on your question, I would recommend separating the containers and naming them with classes or ID's in order to remove stock margins or others that push it down or up.
<div class="container topContainer">
<p>Content here</p>
</div>
<div class="container-fluid midContainer">
<div class="row">
<div class="col-sm-6 leftPad">
<div class="row">
<div class="col-sm-6">
<p>Content here</p>
</div>
<div class="col-sm-6">
<p>Content here</p>
</div>
</div>
</div>
<div class="col-sm-6 rightPad">
<div class="row">
<div class="col-sm-6">
<p>Content here</p>
</div>
<div class="col-sm-6">
<p>Content here</p>
</div>
</div>
</div>
</div>
</div>
<div class="container botContainer">
<p>Content here</p>
</div>
And for setting the background, use the following CSS:
.leftPad {
background-image: url('example.jpg');
}
.rightPad {
background-image: url('example2.jpg');
}
This should wrap it up, and keep it clean without messing anything. To adjust margins and other placements, implement some CSS to those custom classes I've set up on the example.
As a tip I would say that do not use container inside a row or column. Wrap the whole page inside a column and separate the content itself with rows and cols to suite your needs.
Happy coding!
Found few solutions, but all used javascript. So here's my css-only solution. Cheers :)
/* just some styling for better view */
#mix {
background: black;
color: #fff;
}
.left {
background: url('https://static.pexels.com/photos/462254/pexels-photo-462254.jpeg') no-repeat center / cover;
}
.right {
background: url('https://static.pexels.com/photos/534020/pexels-photo-534020.jpeg') no-repeat center / cover;
}
.row {
border-top: 1px solid black;
}
.col-sm-6 {
padding-top: 15px;
padding-bottom: 15px;
}
/* and this below is basically what you need */
#media (min-width: 768px) {
.half-container {
padding-left: 15px;
padding-right: 15px;
max-width: 375px;
}
.left-half-container {
margin-right: -15px;
}
.right-half-container {
margin-left: -15px;
}
}
#media (min-width: 992px) {
.half-container {
max-width: 485px;
}
}
#media (min-width: 1200px) {
.half-container {
max-width: 585px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div id="mix">
<div class="container">
<div class="row">
<div class="left col-sm-6">
<div class="text-justify">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="right col-sm-6">
<div class="text-justify">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>
<div class="container-fluid">
<div class="row">
<div class="left col-sm-6 clearfix">
<div class="half-container left-half-container pull-right text-justify">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="right col-sm-6 clearfix">
<div class="half-container right-half-container pull-left text-justify">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>
</div>
Below is the structure and use images as a background images of container-fluid div
<div class="container-fluid">
<div class="container">
<div class="col-sm-6"> </div>
<div class="col-sm-6"> </div>
</div>
</div>