I have used following strategy: Dividing it into two equal columns col-md-6. Again splitting col-md-6 into 3 columns each i.e. col-md-4. Same for right side. but problem occurs that how to do even spacing between columns on right side.
My code
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="col-md-4 text-center">
<p>My Earning</p>
</div>
<div class="col-md-4 text-center">
<h5>100</h5>
<p>Number of Notes Sold</p>
</div>
<div class="col-md-4 text-center">
<h5>$10,000</h5>
<p>Money Earned</p>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4 ">
<h5>38</h5>
<p>My Downloads</p>
</div>
<div class="col-md-4">
<h5>12</h5>
<p>My Rejected Notes</p>
</div>
<div class="col-md-4 data">
<h5>102</h5>
<p>Buyer Requests</p>
</div>
</div>
</div>
</div>
Based on your design I just created the same kind of layout. I used grid-based we can use flex also.
I added the gutter also.
I think this will help you.
.row div div{
border: 1px solid #000;
text-align:center;
}
.row .no-gutters{
padding:0px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-sm-2 no-gutters">
<div>one</div>
</div>
<div class="col-sm-4 no-gutters">
<div>two</div>
</div>
<div class="col-sm-2">
<div>three</div>
</div>
<div class="col-sm-2">
<div>four</div>
</div>
<div class="col-sm-2">
<div>five</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
Related
.r1{
border:1px solid black;
}
.r2{
border:1px solid black;
text-align:center;
}
.r3{
border:3px solid blue;
text-align:center;
}
.t1{
border:1px solid red;
background-color:red;
text-align:center;
border:1px solid black;
}
.head{
border:2px solid black;
height:50px;
background-color:green;
}
.c{
height: 100px;
border: 1px solid black
}
.cell{
border: 5px solid green;
}
.r4{
}
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="stylo2.css">
<link rel="stylesheet" href="https://necolas.github.io/normalize.css" />
<link href="https://fonts.googleapis.com/css2?family=Russo+One&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
<div class="row r1">
<div class="col-md-12">
<div class="row head">
<div class="col-md-12">
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-1">
</div>
<div class="col-md-9">
Content
</div>
<div class="col-md-1">
</div>
</div>
</div>
</div>
<div class="row head">
<div class="col-md-12">
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-1">
</div>
<div class="col-md-9">
Content
</div>
<div class="col-md-1">
</div>
</div>
</div>
</div>
<div class="row r1">
<div class="col-md-12 c">
Table1
</div>
</div>
<div class="row r2">
<div class="col-md-6 c">
Table2
</div>
<div class="col-md-6 c">
Table3
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="row r3">
<div class="col-md-12">
<div class="row">
<div class="col-md-12 t1">
Heading
</div>
</div>
<div class="row r">
<div class="col-md-1 cell">
1
</div>
<div class="col-md-5 cell">
ABC
</div>
<div class="col-md-5 cell">
234
</div>
<div class="col-md-1 cell">
5
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row r3">
<div class="col-md-12">
<div class="row">
<div class="col-md-12 t1">
Heading
</div>
</div>
<div class="row playerrow">
<div class="col-md-1 cell">
1
</div>
<div class="col-md-5 cell">
ABC
</div>
<div class="col-md-5 cell">
234
</div>
<div class="col-md-1 cell">
5
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Hey,
when I'm on a Desktop Screen, the code is fine, but when I switch to my mobile Device, i would like to have the content of my last row with the cells "1 ABC 234 5" besides each other too (like in desktop version) instead of each col building a new row. Also they shoud have a fixed with that not depends on its content.
Thanks in advance
Easy. Remove the -md- from the classes and leave col-1, col-5 etc. Then they won't be responsive.
I'm having an issue where the card div tags are not the same height. It seems to work when I use container, then row, then col then cards like so:
<div class="container-fluid">
<div class="row">
<div class="col-12 mt-3">
<div class="card">
Card content
</div>
But I would prefer to have the whole lot in a card, I think think it looks a little better.
Thanks
<div class="container-fluid">
<div class="row">
<div class="col-12 mt-3">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-5">
<div class="card-deck">
<div class="card">
<div class="card-header">
Card Header
</div>
<div class="card-body">
Card body 5
<p> Text</p>
</div>
</div>
</div>
</div>
<div class="col-md-7">
<div class="card-deck">
<div class="card">
<div class="card-header">
Card Header
</div>
<div class="card-body">
Card body
</div>
</div>
How it looks on the webpage
Give height: 100%; to .card-deck class, it will take the maximum height of cards and take the same height of both cards.
Try This:
.card-deck{
height: 100%;
}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-12 mt-3">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-5">
<div class="card-deck">
<div class="card">
<div class="card-header">
Card Header
</div>
<div class="card-body">
Card body 5
<p> Text</p>
</div>
</div>
</div>
</div>
<div class="col-md-7">
<div class="card-deck">
<div class="card">
<div class="card-header">
Card Header
</div>
<div class="card-body">
Card body
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I am developing a dashboard with Bootstrap 4 (on top of Angular 5).
Now I can't get around of the following problem:
Let's say I have the following view on my desktop.
I simplified the code to make it more readable. The cards do contain more div's like card-title et cetera and are placed within Angular components.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-9">
<div class="card" style="height: 300px">
card1
</div>
</div>
<div class="col-6 col-md-3">
<div class="card" style="height: 150px">
card2
</div>
<div class="card" style="height: 150px">
card3
</div>
</div>
</div>
You can see the two cols are nicely placed right to the 'bigger' card (see 'Full page' on desktop). Now on mobile (and portrait tablets) the 'card2' and 'card3' are placed under each other but I want them next to each other.
I can do this by generating a new view for mobile only, but in my opinion this could be done easier so I do not have any code duplicates.. But I just don't know how!
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-9">
<div class="card" style="height: 300px">
card1
</div>
</div>
<div class="col-md-3 d-none d-md-block">
<div class="card" style="height: 150px">
card2
</div>
<div class="card" style="height: 150px">
card3
</div>
</div>
<div class="col-6 d-none d-block d-md-none">
<div class="card" style="height: 150px">
card2
</div>
</div>
<div class="col-6 d-none d-block d-md-none">
<div class="card" style="height: 150px">
card3
</div>
</div>
</div>
Does someone know's how to do this in a much cleaner way?
I also tried putting the cards on the right in their own rows, but that creates the same behaviour.
You can nest the card 2 & card 3 in another row>cols, no reason for markup duplication.
https://www.codeply.com/go/AF4sManetn
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-9">
<div class="card" style="height: 300px">
card1
</div>
</div>
<div class="col-12 col-md-3">
<div class="row">
<div class="col-6 col-md-12">
<div class="card" style="height: 150px">
card2
</div>
</div>
<div class="col-6 col-md-12">
<div class="card" style="height: 150px">
card3
</div>
</div>
</div>
</div>
</div>
</div>
I tried looking this up here but I can't find anything related to this specific problem.
I'm trying to make a header which has a button on the left and right of the screen with a logo in the middle, but whenever I make the window smaller or larger the button on the right doesnt stay aligned.
Small window
Large window
Here is the code:
<header>
<div id="container-fluid">
<div class="row">
<div class=" col-2">
Menu
</div>
<div class="col-8 text-center ">
Logo
</div>
<div class="col-2 float-right">
Contact
</div>
</div>
</div>
</header>
What am I missing here?
Thanks in advance.
Fixed it, code now looks like this:
<body>
<header>
<div id="container-fluid">
<div class="row">
<div class="col">
<span class="float-left">Menu</span>
</div>
<div class="col text-center">
Logo
</div>
<div class="col">
<span class="float-right">Contact</span>
</div>
</div>
</div>
</header>
</body>
wrap your content so it can be aligned according to the parent container.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<header>
<div id="container-fluid">
<div class="row">
<div class="col-2">
<span class="float-left">Menu</span>
</div>
<div class="col-8 text-center">
Logo
</div>
<div class="col-2">
<span class="float-right">Contact</span>
</div>
</div>
</div>
</header>
You can use the flex-bootstrap-class and justify-content for this approach:
<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 d-flex justify-content-between bg-light">
<div class="p-2 bg-dark text-light">
Menu
</div>
<div class="p-2 bg-dark text-light">
Logo
</div>
<div class="p-2 bg-dark text-light">
Contact
</div>
</div>
</div>
You havn't defined what size of column grid you are using. Using col-xs,col-sm, col-md,col-lg will have different effects for the particular code. Run the snippet code in full page below and see how the col-size affects when the browser is resized.
Update - Bootstrap 4 has replaced the col-xs with col- .
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<div id="container-fluid">
Col:xs
<div class="row">
<div class=" col-2">
Menu
</div>
<div class="col-8 text-center ">
Logo
</div>
<div class="col-2 float-right">
Contact
</div>
</div>
</div>
<br>
<br>
<div id="container-fluid">
Col:sm
<div class="row">
<div class=" col-sm-2">
Menu
</div>
<div class="col-sm-8 text-center ">
Logo
</div>
<div class="col-sm-2 float-right">
Contact
</div>
</div>
</div>
<br>
<br>
<div id="container-fluid">
Col:md
<div class="row">
<div class=" col-md-2">
Menu
</div>
<div class="col-md-8 text-center ">
Logo
</div>
<div class="col-md-2 float-right">
Contact
</div>
</div>
</div>
<br>
<br>
<div id="container-fluid">
Col:lg
<div class="row">
<div class=" col-lg-2">
Menu
</div>
<div class="col-lg-8 text-center ">
Logo
</div>
<div class="col-lg-2 float-right">
Contact
</div>
</div>
</div>
I have 3 col-md-4(1) col-md-4(2) col-md-4(3) in col-md-12. In mobile or tablet. I want to show middle col-md-4(2) first and then col-md-4(1) col-md-4(3). How to do this properly with respect to bootstrap?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="col-md-4">
<p>abcd</p>
</div>
<div class="col-md-4">
<p>xyzs</p>
</div>
<div class="col-md-4">
<p>mnop</p>
</div>
</div>
</div>
</div>
Reorder the first two columns and use col-xx-push and col-xx-pull to reposition on larger screens:
<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-12">
<div class="col-md-4 col-md-push-4">
<p>Column 2</p>
</div>
<div class="col-md-4 col-md-pull-4">
<p>Column 1</p>
</div>
<div class="col-md-4">
<p>Column 3</p>
</div>
</div>
</div>
</div>
You can not use push and pull when your columns are full width (in your case, below md) so you must have them in the correct order in the DOM to start with.