Bootstrap div placement - html

<div class="row">
<div class="col-xs-6">
<img src="img.png" width="100%" />
</div>
<div class="col-xs-6">
<div class="row"><p>Main text</p></div>
<div class="row"><p>More...</p></div>
</div>
</div>
I need this result:
So I need a picture which takes up 50% of the screen width and then a big title which is centered horizontally, but vertically is on top; and "more..." text which is to the right horizontally, but on the bottom vertically. How do I manage to do this? Can someone help me, please?

Here is your solution: use display flex to make both columns have same height, then use position relative ad absolute to position your columns
.title{
background-color: red;
text-align: center;
}
.title h1{
width: 100%;
}
.description{
background-color: yellow;
}
/*NEW*/
.row{
display:flex;/*makes col have same height*/
}
.details{
position: relative !important;
}
.description{
position: absolute !important;
bottom: 0;
}
.description p{
width: 100%;
text-align: right;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row col-xs-12">
<div class="col-xs-6">
<img src="https://placehold.it/150/150" width="100%" />
</div>
<div class="col-xs-6 details">
<div class="row col-xs-12 title">
<h1>Main text</h1>
</div>
<div class="row col-xs-12 description">
<p>More...</p>
</div>
</div>
</div>

Is it this you mean?
.title{
background-color: red;
text-align: center;
}
.description{
background-color: blue;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row col-xs-12">
<div class="col-xs-6">
<img src="https://placehold.it/150/150" width="100%" />
</div>
<div class="col-xs-6 details">
<div class="row col-xs-12 title">
<h1>Main text</h1>
</div>
<div class="row col-xs-12 description">
<p>More...</p>
</div>
</div>
</div>

Related

How to make a span go through 2 container divs

How to make a span with sticky element float through 2 bootstrap's container divs?
Right now I couldn't make the span element stick on top of the container div, the container will always stay below of the span element. Also, When shrink into mobile view, I would like to have content 1 stay above then follow by span element with image then lastly is content 2. Each of the container has a background-image with it, so I want the span element can move up and down through 2 containers. Thank you so much in advance.
This is what I expected result:
Here is the jsfiddle link: https://jsfiddle.net/oafwmghd/2/
#sticky {
position: -webkit-sticky;
position: sticky;
display: flex;
display: -ms-flex;
display: -webkit-flex;
justify-content: center;
margin-top: 30px;
padding-bottom: 80px;
top: 0;
z-index: 1;
}
<div class="container">
<span><img
src="https://previews.123rf.com/images/sooolnce/sooolnce1611/sooolnce161100038/66323541-realistic-plastic-bottle-for-water-on-a-transparent-background-vector-illustration.jpg"
width=20% height=50% id="sticky"></span>
<section>
<div class="container" style="height:500px; background-color: green;">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-0">
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
Content 1
</div>
</div>
</div>
</section>
<section>
<div class="container" style="height:500px; background-color: red;">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-0">
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
Content 2
</div>
</div>
</div>
</section>
</div>
You might not need these empty elements if you use margin-left:auto (class : ml-auto).
To reorder elements, you need a flex or a grid container , you may reset container to a column flex box (class : d-flex flex-column)
There is nor ordering responsive class (as much as i know), you may create the classes and the breaking point you need and remove t the same time the sticky behavior.
A negative margin or absolute position could be used to avoid image pushing the content down . let's try with position or margin.
An approach could be :
#sticky {
position: -webkit-sticky;
position: sticky;
display: flex;
display: -ms-flex;
display: -webkit-flex;
justify-content: center;
margin-top: 30px;
width: 50%;
top: 1em;
z-index: 1;
margin-left: 0;
border: 0;
order: -1
}
#sticky img {
position: absolute;
}
#media (max-width: 768px) {
.order-sm-1 {
order: 1;
}
#sticky.order-sm-2 {
order: 2;
}
#sticky img {
position: static;
}
.order-sm-3 {
order: 3;
}
#sticky {
position: static;
margin: auto;
width: auto;
}
}
/* demo purpose*/
section {
border: solid;
margin-bottom: 1em;
}
.row .ml-auto {
min-height: 300px;
background: green;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container d-flex flex-column">
<section class="row col-lg-6 col-md-6 col-sm-12 order-sm-2" id="sticky"><img src="https://images.containerstore.com/catalogimages/318610/ColoredStopperBottlesClear_x.jpg?width=1200&height=1200&align=center" width=80%></section>
<section class="order-sm-1">
<div class="container">
<div class="row">
<!--<div class="col-lg-6 col-md-6 col-sm-0"></div>-->
<div class="col-lg-6 col-md-6 col-sm-12 ml-auto">
<p><b>Play the snippet in full page mode and resize the window to checkout the behavior</b></p>
</div>
</div>
</div>
</section>
<section class="order-sm-3">
<div class="container">
<div class="row">
<!--<div class="col-lg-6 col-md-6 col-sm-0"></div>-->
<div class="col-lg-6 col-md-6 col-sm-12 ml-auto">
Content 2
</div>
</div>
</div>
</section>
</div>
follow up from comment :
#sticky {
position: -webkit-sticky;
position: sticky;
display: flex;
display: -ms-flex;
display: -webkit-flex;
justify-content: center;
margin-top: 30px;
width: 30%;
top: 4em;
z-index: 1;
margin-left: 0;
border: 0;
order: -1;
flex: 0 0 auto;
}
#sticky img {
position: absolute;
}
#media (max-width: 768px) {
.order-sm-1 {
order: 1;
}
#sticky.order-sm-2 {
order: 2;
}
#sticky img {
position: static;
}
.order-sm-3 {
order: 3;
}
#sticky {
position: static;
margin: auto;
width: auto;
}
}
/* demo purpose*/
section {
border: solid;
margin-bottom: 1em;
}
.row .ml-auto {
min-height: 200px;
background: green;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="container d-flex flex-column p-0">
<section class="row col-lg-6 col-md-6 col-sm-12 order-sm-2" id="sticky"><img src="https://images.containerstore.com/catalogimages/318610/ColoredStopperBottlesClear_x.jpg?width=1200&height=1200&align=center" width=80%></section>
<section class="order-sm-1">
<div class="container">
<div class="row">
<!--<div class="col-lg-6 col-md-6 col-sm-0"></div>-->
<div class="col-lg-6 col-md-6 col-sm-12 ml-auto">
<p><b>Play the snippet in full page mode and resize the window to checkout the behavior</b></p>
</div>
</div>
</div>
</section>
</div>
<section class="order-sm-3">
<div class="container">
<div class="row">
<!--<div class="col-lg-6 col-md-6 col-sm-0"></div>-->
<div class="col-lg-6 col-md-6 col-sm-12 ml-auto">
Content 2
</div>
</div>
</div>
</section>
</div>
<div class="container">
<section>
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 ml-auto">
Content 3
</div>
</div>
</div>
</section>
<section>
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 ml-auto">
Content 4
</div>
</div>
</div>
</section>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<style>
.row.one{
align-items: stretch;
justify-content: center;
display: flex;
}
.col-lg-6 { width:50%;}
.col-lg-12 { width:100%;}
</style>
<section>
<div class="container">
<div class="row one">
<div class="col-lg-6 col-md-6 col-sm-12" style="background:#006;padding:50px 0;">
Content 1
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12" style="background:#993;padding:50px 0;">
Content 2.1
</div>
<div class="col-lg-12 col-md-12 col-sm-12" style="background:#3FC;padding:50px 0;">
Content 2.2
</div>
</div>
</div>
</div>
</div>
</section>
Hope so this will work for you
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<style>
.row.one{
align-items: stretch;
justify-content: center;
display: flex;
}
.col-lg-6 { width:50%;}
.col-lg-12 { width:100%;}
</style>
<section>
<div class="container">
<div class="row one">
<div class="col-lg-6 col-md-6 col-sm-12" style="background:#006;padding:50px 0;">
Content 1
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12" style="background:#993;padding:50px 0;">
Content 2.1
</div>
<div class="col-lg-12 col-md-12 col-sm-12" style="background:#3FC;padding:50px 0;">
Content 2.2
</div>
</div>
</div>
</div>
</div>
</section>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<style>
.row.one{
align-items: stretch;
justify-content: center;
display: flex;
}
.col-lg-6 { width:50%;}
.col-lg-12 { width:100%;}
</style>
<section>
<div class="container">
<div class="row one">
<div class="col-lg-6 col-md-6 col-sm-12" style="background:#006;padding:50px 0; background:url(https://www.nationalgeographic.com/content/dam/travel/rights-exempt/2018-travel-photographer-of-the-year/magical-mountains/dawn-vestrahorn-iceland-mountains.jpg); background-size:cover;">
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12" style="background:#006;padding:50px 0; background:url(https://www.dw.com/image/48396304_303.jpg); background-size:cover;">
</div>
<div class="col-lg-12 col-md-12 col-sm-12" style="background:#006;padding:50px 0; background:url(https://amp.businessinsider.com/images/5ac3bdf57a74af1b008b4612-960-480.jpg); background-size:cover;">
</div>
</div>
</div>
</div>
</div>
</section>
Hop so this will help you

Bootstrap vertically center heading div responsively

I am trying to vertically center h5 in a div but I want to do it responsively, so those solutions where you set the parent's height to a certain amount of pixels aren't a solution for me.
The h5 with id "channelName" is what I am trying to vertically center in the parent div.
<div class="col-10 text-left channelTab"><h5 id="channelName">Name</h5></div>
#greyBox {
background-color: grey;
}
#title {
color: white;
}
.logo {
max-height: 50px;
max-width: 50px;
border-radius: 50%;
border: 3px solid white;
}
#channelName {
vertical-align: middle;
display: inline-block;
}
#channelRow {
background-color: red;
}
<div class="container-fluid">
<div class="row">
<div class="col-4"></div>
<div id="greyBox" class="col-4 text-center">
<div class="row">
<div class="col-12 text-center">
<h1 id="title">TITLE</h1>
<div class="row" id="channelRow">
<div class="col-2">
<img src="image.png" class="logo"></div>
<div class="col-10 text-left channelTab">
<h5 id="channelName">Name</h5>
</div>
</div>
<div class="col-6">
</div>
</div>
</div>
</div>
</div>
</div>
If this could be done more easily with some more changes to my code, any such tips would be welcome as I am really new to this and still learning.
Add this class to parent of h5 d-flex align-items-center and remove bottom margin of h5
This class (d-flex) will make the display of parent of h5 flex and the align-items-center will vertically center it.
#greyBox {
background-color: grey;
}
#title {
color: white;
}
.logo {
max-height: 50px;
max-width: 50px;
border-radius: 50%;
border: 3px solid white;
}
#channelName {
margin:0;
}
#channelRow {
background-color: red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-4"></div>
<div id="greyBox" class="col-4 text-center">
<div class="row">
<div class="col-12 text-center">
<h1 id="title">TITLE</h1>
<div class="row" id="channelRow">
<div class="col-2">
<img src="image.png" class="logo"></div>
<div class="col-10 text-left d-flex align-items-center channelTab">
<h5 id="channelName">Name</h5>
</div>
</div>
<div class="col-6">
</div>
</div>
</div>
</div>
</div>
</div>

How can I reduce the horizontal space between col-md-4 divs?

HTML
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
I have managed to make vertical spaces between the columns by adding padding to the rows. But now the horizontal spaces between the contents are ways too much. How can I configure the spacing between them?
That large horizontal space is because of the fixed width of the content class if you remove that, you'll see it grow.
You can set the width of the content in % or add a margin to the content class.
.container {
text-align: center;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
}
.row{
padding:15px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-4 col4">
<div class="content">1x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x3</div>
</div>
</div>
<div class="row ">
<div class="col-md-4 col4">
<div class="content">2x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x3</div>
</div>
</div>
<div class="row col4 col4">
<div class="col-md-4 col4">
<div class="content">3x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS Grid to achieve that layout you desire:
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 5px;
position:absolute;
left:50%;
transform:translateX(-50%);
width:80%;
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height:100px;
max-width: 350px;
}
<div class="grid-container">
<div class="item">1x1</div>
<div class="item">1x2</div>
<div class="item">1x3</div>
<div class="item">2x1</div>
<div class="item">2x2</div>
<div class="item">2x3</div>
<div class="item">3x1</div>
<div class="item">3x2</div>
<div class="item">3x3</div>
</div>
Using flexbox:
.flex-container {
display: flex;
/*Generates a flexbox layout with default flex direction as row */
width: 100%;
/* Not really required */
align-items: center;
/*Aligns contents vertically */
justify-content: center;
/*Aligns contents horizontally */
text-align: center;
/*Aligns further text in the center */
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height: 400px;
width: 300px;
margin: 5px;
}
<div class="flex-container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
<div class="flex-container">
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</div>
<div class="flex-container">
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
Use float:left; with class content as below:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
float: left;
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
If I'm reading your request correctly, you are just asking how to make it look like the boxes are in the center of the page, and they are evenly spaced. see if this is what you're looking for:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.col-md-4 {
margin: 5px -10px 0px -4px;;
}
play with the numbers until you get the desired location.
Though I would strongly suggest that you add your own class in addition to col-md-4 to the boxes, which will prevent this new setting to col-md-4 from affecting any future use of this bootstrap class.
in other words . . .
CSS:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.box-move {
margin: 5px -10px 0px -4px;;
}
and HTML:
<div class="container">
<div class="row">
<div class="col-md-4 box-move">
<div class="content">1x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">2x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">3x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x3</div>
</div>
</div>
</div>
You can remove a lot of the stuff there and simplify it to make it responsive width a set margin:
.contents {
background-color: black;
color: white;
height: 500px;
margin: 20px 0px;
}
<div class="container-fluid text-center">
<div class="row">
<div class="col-md-4">
<div class="contents">1x1</div>
</div>
<div class="col-md-4">
<div class="contents">1x2</div>
</div>
<div class="col-md-4">
<div class="contents">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">2x1</div>
</div>
<div class="col-md-4">
<div class="contents">2x2</div>
</div>
<div class="col-md-4">
<div class="contents">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">3x1</div>
</div>
<div class="col-md-4">
<div class="contents">3x2</div>
</div>
<div class="col-md-4">
<div class="contents">3x3</div>
</div>
</div>
</div>
</div>

Center divs, into another div using Boostrap 3

I want to center two divs, into another div (horizontally). Can someone tell me how can I do it, in the bellow code? I want to have the two divs with the classes box-left and box-right, in the middle of the div with the class outer:
<html>
<head>
<style>
.container{
background-color: blue;
}
.outer{
text-align: center;
}
.width-600{
width:600px;
text-align:left;
margin-right: auto;
margin-left: auto;
}
.box-left{
background-color: yellow;
}
.box-right{
background-color: green;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="outer">
<div class="row width-600">
<div class="col-xs-12 col-md-4">
<div class="box-left">left</div>
</div>
<div class="col-xs-12 col-md-8">
<div class="box-right">right</div>
</div>
</div>
</div>
</div>
</body> </html>
You can use display:flex and justify-content:center on .outer class ,would center the two rows
check the following snippet
.container {
background-color: blue;
}
.outer {
display:flex;
justify-content:center;
}
.width-600 {
width: 400px;
}
.box-left {
background-color: yellow;
}
.box-right {
background-color: green;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<div class="outer">
<div class="row ">
<div class="col-xs-12 col-md-4">
<div class="box-left">left</div>
</div>
<div class="col-xs-12 col-md-8">
<div class="box-right">right</div>
</div>
</div>
</div>
</div>
replace this body in your html and see if it works for you..
<body>
<div class="container">
<div class="row width-600">
<div class="col-lg-2 col-sm-2 col-md-2 col-xs-2"></div>
<div class="col-lg-4 col-sm-4 col-md-4 col-xs-4">
<div class="box-left">left</div>
</div>
<div class="col-lg-4 col-sm-4 col-md-4 col-xs-4">
<div class="box-right">right</div>
</div>
<div class="col-lg-2 col-sm-2 col-md-2 col-xs-2">
</div>
</div>
</div>
</body>

Bootstrap 3 Half background color

I need to align TEXT of container-fluid at same padding/margin like container.
You have example in this image:
EDIT: See 2nd photo, i want that padding to be the same on container-fluid / container, and when you minimize screen to be responsive..
.nopadding {
margin: 0 !important;
padding: 0 !important;
}
.bg {
background-color: #f3f3f3;
}
.left {
height: 650px;
}
.img-bg {
margin-right: 0px !important;
height: 650px;
background: url(http://placehold.it/850x650) no-repeat center center;
background-size: cover;
}
<section id="id1">
<div class="container-fluid">
<div class="row">
<div class="col-md-7 nopadding bg">
<div class="left">
<h2>TEXT</h2>
</div>
</div>
<div class="col-md-5 nopadding img-bg">
</div>
</div>
</div>
</section>
Here is my solution:
HTML part:
<div class="container-fluid">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 text no-padding center-flex">
<p>Text</p>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 image no-padding">
<div class="full-width"></div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 text no-padding center-flex">
<p>Text</p>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 text no-padding center-flex">
<p>Text</p>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 text no-padding center-flex">
<p>Text</p>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 text no-padding center-flex">
<p>Text</p>
</div>
</div>
</div>
CSS part:
.center-flex {
/* Internet Explorer 10 */
display:-ms-flexbox;
-ms-flex-pack:center;
-ms-flex-align:center;
/* Firefox */
display:-moz-box;
-moz-box-pack:center;
-moz-box-align:center;
/* Safari, Opera, and Chrome */
display:-webkit-box;
-webkit-box-pack:center;
-webkit-box-align:center;
/* W3C */
display:box;
box-pack:center;
box-align:center;
}
.container-fluid .text {
background: #515467;
height: 650px;
}
.container .text {
background: #737373;
height: 300px;
}
.container-fluid .image {
background: #2D2D2D;
height: 650px;
}
.full-width {
width:100%;
height:100%;
height:calc(100% - 1px);
background-image:url('http://placehold.it/850x650');
background-size:cover;
}
.full-width img {
width:100%;
}
.no-padding {
padding: 0 !important;
}
.no-margin {
margin: 0 !important;
}
You can see the jsfiddle result: https://jsfiddle.net/DTcHh/18725/
try with this below code it may help you
.text1{
background : #0f74bd;
padding : 50px;
color : white;
font-weight : bold;
}
.image{
background : #000;
padding : 50px;
color : white;
font-weight : bold;
}
.text{
background : #9ea3a9;
padding : 50px;
color : white;
font-weight : bold;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<section>
<div class="container-fluid">
<div class="row">
<div class="col-sm-6 col-md-6 col-xs-6 text1">
TEXT1
</div>
<div class="col-sm-6 col-md-6 col-xs-6 image">
IMAGE
</div>
</div>
</div>
<div class="container text">
<div class="row">
<div class="col-sm-6 col-md-6 col-xs-6">
TEXT2
</div>
<div class="col-sm-6 col-md-6 col-xs-6">
TEXT3
</div>
<div class="col-sm-6 col-md-6 col-xs-6">
TEXT2
</div>
<div class="col-sm-6 col-md-6 col-xs-6">
TEXT3
</div>
</div>
</div>
</section>
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
</head>
<body>
<div style="background-color: blue" class="container-fluid">
<h1 style="text-align:center">Container-Fluid</h1>
<div class="row">
<div style="text-align:center" class="col-xs-6">TEXT 1</div>
<div style="text-align:center" class="col-xs-6">IMAGE</div>
</div>
<div style="background-color: yellow" class="container">
<h1 style="text-align:center">Container</h1>
<div class="row">
<div style="text-align:center" class="col-xs-6">Text 1</div>
<div style="text-align:center" class="col-xs-6">Text 2</div>
<div style="text-align:center" class="col-xs-6">Text 3</div>
<div style="text-align:center" class="col-xs-6">Text 4</div>
</div>
</div>
</div>
</body>
</html>
Is this what u want, using bootstrap