I know this may be easy for most of you but I'm stuck with this issue.
I need to implement this design:
Layout Design
... and for now I've got this Current layout.The general structure is a row with col-3 and col-9, this col-9 has two rows, one for name and job title, and the other one for statistics in the page (col-3 for each of them). I need them to fill the height of his parent, but height property doesn't work. Which could be a clean solution? Thanks a lot.
Here is the structure, it's pretty simple tho.
<div class="row profile-header">
<div class="col-md-3 user-image text-center">
<img ...>
<span>..</span>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<h2 class="text-white">...</h2>
<h4 class="text-muted">...</h4>
</div>
</div>
<div class="row text-center">
<div class="col-md-3 stat">
<h3>...</h3>
<small>...</small>
</div>
...
</div>
</div>
Use position: relative on the parent and then position:absolute; bottom: 0; on the children.
Nice explanation there.
Flexbox would be my recommendation although CSS tables might be an option too.
Codepen Demo
Snippet Demo (view Fullscreen)
.user-image {
background: pink;
}
.user-image img {
display: block;
margin: auto;
}
.profile-header {
display: flex;
}
.right {
background: #c0ffee;
display: flex;
flex-direction: column;
}
.stats {
margin-top: auto;
}
.stat {
background: lightgrey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="row profile-header">
<div class="col-md-3 user-image text-center">
<img src="http://www.fillmurray.com/300/200" alt="" />
<span>User Ranking</span>
</div>
<div class="col-md-9 right">
<div class="row">
<div class="col-md-12">
<h2 class="text-white">User Name</h2>
<h4 class="text-muted">reference</h4>
</div>
</div>
<div class="row text-center stats">
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
</div>
</div>
Related
I'm working with bootstrap 4 and following codes,
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.css">
<div class="card-header rounded-0 border border-dark">
<div class="row">
<div class="col-12 col-md-4 ">
<img src="{{asset('images/usa.jpg')}}" alt="..." class="rounded-circle">
</div>
<div class="col-12 col-md-8 ">
<p>This is not a game fgfhg dfghdh dhdhdf dfgdhfhg dfdfhfh dfhdfhdf dfhdfh</p>
</div>
</div>
</div>
I need display above two div elements in the same row on large screen and need separate two rows (image is above and paragraph is under the image) when it is displaying mobile device. I use following col-12 col-sm-8 col-md-6 col-lg-4 col-xl-3 item codes in side to the div but not success.
how could I manage this problem?
View in Full Page , You will get it
body {
padding-top: 40px;
}
.col-sm-6 {
background: #ccc;
}
.other {
background: #a4a4a4;
}
.p {
text-align: center;
padding-top: 120px;
}
.p a {
text-decoration: underline;
color: blue;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-sm-6">
<h1>Bootstrap Grid Demo</h1>
</div>
<div class="col-sm-6 other">
<h1>2 Columns</h1>
</div>
</div>
</div>
<p class="p">Demo by Jabir Sayed. See article.</p>
I am doing a simple page with a bootstrap grid and I am having some problems with placing the middle row occupying the full height in the middle.
These are the 3 rows: page
I want to place the row with the logo in the middle, but I am having problems with it. I placed height: 100%;, height: auto;. I even placed the container height to 100% and auto and nothing works!
I think there is a concept about bootstrap heigh that I am missing, because its the heigh that I have problems
html:
<div class="container-fluid">
<div class="row">
<div class="col-md-1 col-2">
<img id="menuIcon" (click)="toggleRightSidenav()" onmouseover="this.src='../../../assets/Images/generic/menuIcon_hover.png'" src="/assets/Images/generic/menuIcon.png" onmouseout="this.src='/assets/Images/generic/menuIcon.png'">
</div>
<div class="col-md-10 col-8">
</div>
<div class="col-md-1 col-2">
<img id="helpIcon" routerLink="/guide" onmouseover="this.src='../../../assets/Images/home/helpIconHover.png'" src="/assets/Images/home/helpIcon.png" onmouseout="this.src='/assets/Images/home/helpIcon.png'">
</div>
</div>
<div class="row row align-items-center mh-100" >
<div class= "col-md-12">
<img id="logo" src="/assets/Images/home/Logo.png">
</div>
</div>
<div class="row align-items-center justify-content-around fixed-bottom">
<div class="col-md-2 col-sm-2">
<img id="addButton" routerLink="/addPlayer" onmouseover="this.src='../../../assets/Images/generic/addIcon_hover.png'" src="../../../assets/Images/generic/addIcon.png" onmouseout="this.src='/assets/Images/generic/addIcon.png'" />
</div>
<div class="col-md-2 col-sm-2">
<p>Players Waiting: {{playerWaiting}} </p>
</div>
<div class="col-md-2 col-sm-2">
<p>Listed Players: {{playersListed}}</p>
</div>
<div class="col-md-2 col-sm-2">
<img id="searchButton" routerLink="/search" onmouseover="this.src='../../../assets/Images/generic/searchIcon_hover.png'" src="../../../assets/Images/generic/searchIcon.png" onmouseout="this.src='/assets/Images/generic/searchIcon.png'" />
</div>
</div>
</div>
css:
div{
border: yellow 1px solid;
}
#menuIcon{
width: 100%;
height: auto;
}
#helpIcon{
width: 100%;
height: auto;
}
#addButton{
width: 100%;
height: auto;
max-width: 127px;
}
#searchButton{
width: 100%;
height: auto;
max-width: 127px;
}
https://www.codeply.com/p/Xd0xi5hFNc
Couple of things.
To be able to fill several rows, you'd need a height for the container div.
Current HTML
<div class="container-fluid">
Update as
<div class="container-fluid d-flex vh-100 flex-column">
Now you can easily make your middle div fill the remaining gap by adding a fill-height class.
Current HTML
<div class="row row align-items-center mh-100" >
Update as
<div class="row row align-items-center fill-height">
Add this to your css
.fill-height {
flex: 1;
}
.fixed-bottom {
position: sticky;
}
jsFiddle
My goal is to achieve the following image on my page:
I managed to achieve this with the HTML and CSS you can find below, but it doesn't seem very viable, because the sidebar is losing it's physical height because of the position: absolute.
I'm wondering if it's possible to make one row with two columns on the left and a sidebar on the right, without having to use positioning.
I tried position: relative with a negative top, but since the top col-md-9 has a changing height (depending on what is entered), I can't give it a negative top. It'll simply be too static and impossible to maintain.
Changing the order in the HTML doesn't change anything, since the physical height of the sidebar will move the 2nd content down.
.sidebar {
position: absolute;
width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-9">
Changing content
</div>
<div class="col-md-3 sidebar">
Sidebar
</div>
<div class="col-md-9">
More content
</div>
</div>
I use xs columns for this example, but you can change to md in your page.
Firstly create a 9-column and a 3-column div. Then put two divs inside the 9-column one.
.content, .sidebar {
margin: 10px;
padding: 20px;
}
.content {
background-color: navy;
color: white;
}
.sidebar {
background-color: yellow;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row wrapper">
<div class="col-xs-9">
<div class="row">
<div class="col-xs-12">
<div class="content">Content</div>
</div>
<div class="col-xs-12">
<div class="content">Content</div>
</div>
</div>
</div>
<div class="col-xs-3">
<div class="sidebar">Sidebar</div>
</div>
</div>
You can nest col-x-x inside other col-x-x
You just have to create 2 parents: content and sidebar, then add multiple contents into the content parent :
<div class="row">
<div class="col-md-9">
<div class="col-md-12">
Content
</div>
<div class="col-md-12">
More content
</div>
</div>
<div class="col-md-3 sidebar">
Sidebar
</div>
</div>
You cannot have more that 12 columns in a row unless it is not defined in your custom grid.
What you can try is this:
<div class="row">
<div class="col-md-9">
<div class="row">
<div class="col-sm-12">
Changing content
</div>
<div class="col-sm-12">
More content
</div>
</div>
</div>
<div class="col-md-3" style="position: relative;">
<div class="row">
<div class="col-sm-12 sidebar">
Sidebar
</div>
</div>
</div>
</div
As a solution, you can make sidebar to stay at the right side of screen if you'll make left section overflow: auto.
.sidebar {
height: 100vh;
background: lightgreen;
}
.left-section {
height: 100vh;
background: lightblue;
overflow: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-9 left-section">
<div class="row">
<div class="col-sm-12">
Changing content
</div>
<div class="col-sm-12">
More content
</div>
</div>
</div>
<div class="col-sm-3 sidebar">
Sidebar
</div>
</div>
</div>
JSFiddle: https://jsfiddle.net/s0m142c4/
I am trying to use foundation's grid to build a grid of photos.
I want it to look like this with all of the blocks representing photos.
:
I am, as foundation's documentation suggests, nesting two columns inside of one column, and the third column just contains its image.
HTML:
<div class="row grid-row">
<div class="large-6 columns">
<div class="row">
<div class="large-12 columns grid-img port">
<img src="img/tile1-new.jpg" />
</div>
</div>
</div>
<div class="large-6 columns">
<div class="row">
<div class="large-4 columns grid-img land">
<img src="img/tile7.jpg" />
</div>
<div class="large-4 columns grid-img land">
<img src="img/tile3.jpg" />
</div>
</div>
<div class="row">
<div class="large-4 columns grid-img">
<img src="img/tile7.jpg" />
</div>
<div class="large-4 columns grid-img">
<img src="img/tile3.jpg" />
</div>
</div>
</div>
</div>
CSS:
.grid-img{
text-align: center;
}
.grid-img img{
min-width:90%;
}
.grid-img.port img{
min-width:100%;
}
.grid-row{
height:600px;
}
But it's coming out like this instead:
Any idea how to get the images to fill their nested columns and maintain a padded grid like my example?
This is very close, you needed to use 100% width for the images and then change large-4 columns to large-6 as they were never going to take up 50% each which they needed to do.
You can now tweak bottom margin to make the layout work a little bit better. There's a really geeky way to do this which is Masonry.js or Isotope.js, it resizes containers, but might be a bit heavy handed to do what html and css can do pretty well. See below:
/*.grid-img {
text-align: center;
}
.grid-img img {
min-width: 90%;
}
.grid-img.port img {
min-width: 100%;
}
.grid-row {
height: 600px;
}
*/
.grid-img img {
width: 100%;
margin-bottom: 2em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.0/foundation.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.0/foundation.min.css" rel="stylesheet" />
<div class="row grid-row">
<div class="large-6 columns">
<div class="row">
<div class="large-12 columns grid-img port">
<img src="http://placehold.it/600x600" />
</div>
</div>
</div>
<div class="large-6 columns">
<div class="row">
<div class="large-6 columns grid-img land">
<img src="http://placehold.it/600x600" />
</div>
<div class="large-6 columns grid-img land">
<img src="http://placehold.it/600x600" />
</div>
</div>
<div class="row">
<div class="large-6 columns grid-img">
<img src="http://placehold.it/600x600" />
</div>
<div class="large-6 columns grid-img">
<img src="http://placehold.it/600x600" />
</div>
</div>
</div>
</div>
I'm trying to use Bootstrap 3 to make a grid-based template for a modal (which I'm also using Bootstrap for). The modal appears, and all the content is there ... but the styling is off. It looks like the row classes don't fill their parent containers, even though there's no styling that should make that happen. Here's a screenshot - you can see that neither the row in the header nor the row in the body take the width of their parent. I've tried poking around other SO posts for information, but I can't seem to find anything on why a row wouldn't fill its parent width.
Update:
Here's a JSFiddle. It looks like it actually works on JSFiddle ... which means it's not a problem with the immediate template, so I'm looking into other possible causes. Thanks for the tip, calvin!
HTML
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header ht-modal-header">
<h1>
Bombay Teen Challenge
</h1>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<address>
1 Chium Village, Ambedkar Road<br/>
Bandra West<br/>
Mumbai 400052
</address>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<abbr>e: </abbr> kkdevaraj#bombayteenchallenge.org<br/>
<abbr>p: </abbr> +91 22 2604 2242
</div>
</div>
</div>
<div class="modal-body ht-modal-body">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="types">
<span class="prevention-label"></span> Prevention, Education, Teen
</div>
<div class="facebook">
<span class="fa fa-facebook-square fa-2x"></span> BombayTeenChallenge
</div>
<div class="twitter">
<span class="fa fa-twitter-square fa-2x"></span> #BombayTC
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="people">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<label>People: </label>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
Dr. Rama R. Rao<br/>
Monte Hackney
</div>
</div>
</div>
<div class="partners">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<label>Partners: </label>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
None Available
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
LESS
.prevention-label {
width: 24px;
height: 24px;
line-height: 24px;
display: inline-block;
background-color: #4ECDC4;
}
.ht-modal-header {
a {
&:hover, &:focus {
color: white;
}
color: white;
}
color: white;
background: linear-gradient(#ht-teal, darken(#ht-teal, 5%));
background: -webkit-gradient(#ht-teal, darken(#ht-teal, 5%));
background: -o-linear-gradient(#ht-teal, darken(#ht-teal, 5%));
background: -moz-linear-gradient(#ht-teal, darken(#ht-teal, 5%));
}
If you nest rows in columns you must understand that inside a .col-lg-6 .row the whole thing starts new (at 100%) and for you you to fill it have to use .col-lg-12 inside of it.
This snippet should work for you
<div class="col-sm-6">
<div class="people">
<div class="row">
<div class="col-sm-12">
<label>People: </label>
</div>
<div class="col-sm-12">
Dr. Rama R. Rao<br/>
Monte Hackney
</div>
</div>
</div>
<div class="partners">
<div class="row">
<div class="col-sm-12">
<label>Partners: </label>
</div>
<div class="col-sm-12">
None Available
</div>
</div>
</div>
</div>