I have a row with two cols:
a) For the name of the list
b) For an edit button.
col-md-6 works great for when the list's name is short, but when is longer it renders clunky.
Clunky:
html
<div class="row">
<div class="col-md-6">
<h1 class="box">Lista: {{ lista.name }}</h1>
</div>
<div class="col-md-6">
<button id="editList" class="btn btn-primary">Editar</button>
</div>
</div>
<hr>
It gets worse for mobiles, where the list's name should be on top of the button "Editar".
if you use bootstrap
<div class="row">
<div class="col-md-8 col-sm-6">
<h1>welcome to my blog</h1>
</div>
<div class="col-md-4 col-sm-6>
<button class="btn">hello</button>
</div>
</div>
just css
<div class="contains">
<div class="text">
<h1>welcome to my blog</h1>
</div>
<div class="button>
<button class="btn">hello</button>
</div>
</div>
<style>
.contains {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.text{
width: 60%;
}
.button{
width: 40%;
}
</style>
add (col col-md-6) not (col-md-6)
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col col-md-6">
<h1 class="box">Lista: Mi Primary List</h1>
</div>
<div class="col col-md-6">
<button id="editList" class="btn btn-primary">Editar</button>
</div>
</div>
<hr>
Related
I am close to achieving this look and behavior but I am having issues with the scrolling of the right column. The scroll bar appears but does not scroll the content on the right column. Should look like this:
.
Currently looks like this:
There are probably multiple approaches or changes I can take or make but any suggestions are welcome! Code is provided below.
.scroller {
overflow-x: scroll;
white-space: nowrap;
}
.row {
display: flex;
flex-wrap: nowrap;
}
.col-md-4 {
min-width: 240px;
}
.col-md-8 {
flex-grow: 1;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<div class="row">
<div class="col-4" style="min-width: 240px;">
<div class="row pb-1">
<div class="col-3 offset-3">
<b>NAME</b>
</div>
</div>
<div class="row row-striped align-items-center pb-1 pt-1">
<div class="col-3">
<img src="https://media.api-sports.io/football/players/730.png" alt="player photo" width="40px" height="40px">
</div>
<div class="col-9 player-table-text">
<div>
Thibaut Courtois
<span class="ps-1 player-number-text">1</span>
</div>
</div>
</div>
</div>
<div class="col scroller" style="min-width: 500px;">
<div class="row pb-1">
<div class="col-2 offset-1">
<b>POS</b>
</div>
<div class="col-2">
<b>AGE</b>
</div>
<div class="col-2">
<b>HT</b>
</div>
<div class="col-2">
<b>WT</b>
</div>
<div class="col-2">
<b>NAT</b>
</div>
</div>
<div class="row row-striped align-items-center pb-1 pt-1 player-table-text" style="height:48px;">
<div class="col-2 offset-1">
GK
</div>
<div class="col-2">
30
</div>
<div class="col-2">
6' 7"
</div>
<div class="col-2">
212 lbs
</div>
<div class="col-2">Belgium</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-1">
<p style=" writing-mode: vertical-rl; text-align: center; transform:scale(-1);">Total Number of Correct and Wrong Number</p>
</div>
<div class="col-sm-11">
<div class="row" style="height: 400px">
<canvas id="{{ answer.id }}_barChart" class="bar_chart"></canvas>
</div>
</div>
</div>
</div>
Above is the code for my work, i tried to make the text align to middle by put text-align:center or <center> xxx </center> , but it's still not in the middle
https://prnt.sc/m8hPkJ3N5x4v here is the image
Just add the following 3 more bootstrap classes d-flex align-items-center justify-content-center, in your heading div.
so your heading div will be <div class="col-sm-1 d-flex align-items-center justify-content-center">
check below.
.container{
background-color:aqua;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-1 d-flex align-items-center justify-content-center">
<p style=" writing-mode: vertical-rl; transform:scale(-1);" class="align-middle">
Total Number of Correct and Wrong Number
</p>
</div>
<div class="col-sm-11">
<div class="row" style="height: 400px">
Your Chart.
</div>
</div>
</div>
</div>
I try to nest multiple rows in a column.
In the end it should look like
The problem is that I centered the whole thing vertically and the css rule seems to apply also on my child rows. How can I stop this alignment and make it look like I want?
Here is what I got so far:
.vertical-center {
min-height: 100%;
min-height: 100vh;
display: flex;
align-items: center;
}
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="row justify-content-center vertical-center">
<div class="col-auto">
<span id="field1">text</span>
</div>
<div class="col-auto">
<span id="field2">text</span>
</div>
<div class="col-auto">
<span id="field3">text</span>
</div>
<div class="col-auto">
<span id="field4">=</span>
</div>
<div class="col-auto">
<div class="row">
<div class="col">
<input type="text" id="field5"/>
</div>
</div>
<div class="row">
<div class="col-auto">
<div id="xy">Bar</div>
</div>
</div>
<div class="row">
<div class="col-auto">
<div id="h">Bar2</div>
</div>
</div>
</div>
</div>
</body>
</html>
Align the container instead of aligning the content. Apply your CSS to the body
body {
min-height: 100%;
min-height: 100vh;
display: flex;
align-items: center;
}
<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"> <!-- this is mandatory when using row -->
<div class="row justify-content-center">
<div class="col-auto">
<span id="field1">text</span>
</div>
<div class="col-auto">
<span id="field2">text</span>
</div>
<div class="col-auto">
<span id="field3">text</span>
</div>
<div class="col-auto">
<span id="field4">=</span>
</div>
<div class="col-auto">
<div class="row">
<div class="col">
<input type="text" id="field5" />
</div>
</div>
<div class="row">
<div class="col-auto">
<div id="xy">Bar</div>
</div>
</div>
<div class="row">
<div class="col-auto">
<div id="h">Bar2</div>
</div>
</div>
</div>
</div>
</div>
i want to show 2 div in the center. i have divs which shows like this. i just want second row div in the center.
req design like this
output
---- ------- -------
------- -------
desired output
----- ------- -------
------- -------
code
<div class="row">
<div class="features">
<div class="col-md-4 col-sm-6 wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="600ms">
<div class="feature-wrap">
<i class="fa fa-pencil" ></i>
<h2>One</h2>
<h3>one</h3>
</div>
</div><!--/.col-md-4-->
<div class="col-md-4 col-sm-6 wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="600ms">
<div class="feature-wrap">
<i class="fa fa-line-chart"></i>
<h2>Two</h2>
<h3>Two</h3>
</div>
</div><!--/.col-md-4-->
<div class="col-md-4 col-sm-6 wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="600ms">
<div class="feature-wrap">
<i class="fa fa-database"></i>
<h2>three</h2>
<h2>Three</h2>
<h3>Three</h3>
</div>
</div><!--/.col-md-4-->
<div>
<div class="col-md-4 col-sm-6 wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="600ms" align="">
<div class="feature-wrap">
<i class="fa fa-book" align=""></i>
<h2>Four</h2>
<h3>Coming Soon...</h3>
</div>
</div><!--/.col-md-4-->
<div class="col-md-4 col-sm-6 wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="600ms">
<div class="feature-wrap">
<i class="fa fa-mobile"></i>
<h2>Five</h2>
<h3>Coming Soon...</h3>
</div>
</div><!--/.col-md-4-->
</div>
</div><!--/.services-->
</div>
</div><!--/.services-->
</div>
jsfiddle code
https://jsfiddle.net/tccu9ue8/4/
As suggested by #sahil Dhir you could use offset values for your layout like
Col-md-offset-[number of column offsets]
In your case giving column offset of 2 to the first element of second row should do the magic.
Here is a working fiddle. https://jsfiddle.net/tccu9ue8/6/
Let me know if you need more info Cheers!!!
This is one way of achieving what you asked for:[basic CSS (padding and margin) can be applied for better results]
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body class="container">
<div class="row">
<div class="col-md-4 col-xs-4 col-lg-4 col-sm-4" align="center">
<button class="btn btn-primary">1ST</button>
</div>
<div class="col-md-4 col-xs-4 col-lg-4 col-sm-4" align="center">
<button class="btn btn-primary">2nd</button>
</div>
<div class="col-md-4 col-xs-4 col-lg-4 col-sm-4" align="center">
<button class="btn btn-primary">3rd</button>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6 col-xs-6 col-lg-6 col-sm-6" align="center">
<button class="btn btn-primary">4th</button>
</div>
<div class="col-md-6 col-xs-6 col-lg-6 col-sm-6" align="center">
<button class="btn btn-primary">5th</button>
</div>
</div>
</body>
</html>
Hope this helps serve your purpose.
The simple way you can achieve this design by using flexbox.
You can find a good guide from MDN here.
For your implementation, You dont have to use bootstrap.
Just wrap two lines, create one line full width, another with half width, and use flexbox properties to align them as you wish.
.line {
display: flex;
justify-content: space-between;
}
.line--second {
width: 50%;
margin: 0 auto;
justify-content: space-between;
}
<div class="wrapper">
<div class="line line--first">
<div class="item">One </div>
<div class="item"> Two </div>
<div class="item"> Three </div>
</div>
<div class="line line--second">
<div class="item">Four </div>
<div class="item">Five </div>
</div>
</div>
Hope this what you meant.
you need to use display:inline-block instead of float: left for bootstrap column https://jsfiddle.net/7mbs9cjj/
.block {
height: 200px;
background: #333;
}
.h-center .col-sm-4 {
margin-bottom: 20px;
float: none;
display: inline-block;
vertical-align: top;
margin-right: -4px;
}
.row {
text-align: center;
display: block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="row h-center">
<div class="col-sm-4">
<div class="block"></div>
</div>
<div class="col-sm-4">
<div class="block"></div>
</div>
<div class="col-sm-4">
<div class="block"></div>
</div>
<div class="col-sm-4">
<div class="block"></div>
</div>
<div class="col-sm-4">
<div class="block"></div>
</div>
</div>
I have here my example in fiddle. I am using bootstrap. What I want to do is have the '150' and the 'points' be in the same row right next to each other. Is this possible? How can I do this?
My html looks like this:
<div class="container">
<div class="row">
<div class="col-md-6">
<h4>Content Submissions: </h4>
</div>
<div class="col-md-6">
<div class="col-md-4 pull-right">
<h2>user name</h2>
<div class="row-fluid">
<h2><strong>150 </strong></h2>
<p><small>Points</small></p>
</div>
Account Settings
</div>
</div>
</div>
</div>
Use following css:
.row-fluid {
display: flex;
}
h2 {
margin-top: 0;
}
Working Fiddle
.row-fluid {
display: flex;
align-items: center;
}
h2 {
margin-top: 0;
margin-right: 10px;
}
hi i have made few changes to your html, try this
<div class="container">
<div class="row">
<div class="col-md-6">
<h4>Content Submissions: </h4>
</div>
<div class="col-md-6">
<div class="col-md-4 pull-right">
<h2>user name</h2>
<div class="row-fluid">
<div class="col-lg-6 col-xs-6">
<h2><strong>150 </strong></h2>
</div>
<div class="col-lg-6 col-xs-6">
<p><small>Points</small></p>
</div>
</div>
Account Settings
</div>
</div>
</div>
</div>
<style>
h2{margin:0;}
</style>