I need each row to have same height - css

I need to make divs look like table data, I have used display: table-cell and display: table properties but i didn't get expected layout. I need each row to have same height.
please check below code
.publishers {
margin: 45px 0;
margin-right: 60px;
}
.publishers .col-xs-6:nth-child(odd) .publisher {
margin-right: -10px;
}
.publishers .col-xs-6:nth-child(even) .publisher {
margin-left: -10px;
}
.publishers .publisher {
background-color: #f1efef;
margin-bottom: 10px;
}
.publishers .publisher .media {
padding: 10px;
}
.publishers .publisher .media .media-left img {
width: 128px;
height: 128px;
}
.publishers .publisher .media .media-body h3 {
font-size: 30px;
font-weight: 400;
}
/***** my try *****/
.publishers{
display:table;
}
.publishers .publisher{
display: table-cell;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<section class="publishers">
<div class="row">
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="http://www.cengage.com
">
<img style=" height: auto;" src="Publishers/7726f4a3-b23d-4af1-879d-57da2a567bd1.jpg" alt="...">
</a>
</div>
<div class="media-body">
<a href="http://www.cengage.com
"><h3>Cengage</h3></a>
<p class="description">A company that delivers highly..
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="http://www.elsevier.com
">
<img style=" height: auto;" src="Publishers/b3723614-ea79-4b24-a9fb-ae0c1da9a3c4.png" alt="...">
</a>
</div>
<div class="media-body">
<a href="http://www.elsevier.com
"><h3>Elsevier </h3></a>
<p class="description">A world’s leading publisher of science and health information serves more than 30 million scientists, students and health and information professionals worldwide
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="http://eu.wiley.com/WileyCDA/Section/index.html
">
<img style=" height: auto;" src="Publishers/ff9e4261-36a1-4cd3-bf9c-c169ff8661eb.png" alt="...">
</a>
</div>
<div class="media-body">
<a href="http://eu.wiley.com/WileyCDA/Section/index.html
"><h3>WILEY</h3></a>
<p class="description">Wiley is a global publisher of print and electronic products, textbooks, and other educational materials, for students both undergraduate and postgraduate, specializing in scientific, technical, and medical books and journals; professional and consumer books and subscription services. Wiley has approximately 22,700 active titles and 400 journals, and publishes 2000 new titles in a variety of print and electronic formats each year
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="https://www.pearson.com/
">
<img style=" height: auto;" src="Publishers/d18fbae5-1587-4b06-a0e4-8b0b1ec4ab13.jpg" alt="...">
</a>
</div>
<div class="media-body">
<a href="https://www.pearson.com/
"><h3>Pearson</h3></a>
<p class="description">Global leader in educational publishing offers comprehensive range of educational programs, in all subjects, for every age and level of student, from preK-12 through higher education and on into professional life.
</p>
</div>
</div>
</div>
</div>
</div>
</section>

.publishers .row {
display: flex;
}
If you don't need IE9 and below support you can use flex this by default uses align-items: stretch which makes all the children full height

If content is static then u can take height of longest div and assign to all.
If content is dynamic then:
$(document).ready(function() {
var maxHeight = -1;
$('.features').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$('.features').each(function() {
$(this).height(maxHeight);
});
});

You could loop through each of the .features, find the max then apply that height to all blocks of the same class.
$(document).ready(function() {
var blockHeights;
blockHeights = [];
$('.features').each(function() {
blockHeights.push($(this).height());
});
$('.features').height(Math.max.apply(Math, blockHeights));
});
If you load your content through ajax or some other method after document ready simply move this into a function and call that when ready.
Probably worth setting a height (or height:auto) on the block as a style incase java script is off or doesn't load correctly, just to ensure the content is always visible.

You were almost there. display:table works. The problem is that your bootstrap is adding float to your divs, which break the table. Add in your css float:none; and it will work. Jsfiddle for example : http://jsfiddle.net/42dy9aLm/

Related

Using Bootstrap Grid, Why Can I Not Space Out My Divs?

I'm working on my first web dev portfolio and am trying to incorporate the Bootstrap Grid system to the project links. I've searched through Bootstrap's documentation (v4.5), Stack Overflow, and just googling various searches to death. I've tried every solution I've found and am still getting nowhere. The closest I've come to a result is changing all three col-lg-4 to col-lg33. That did create the space, but then the padding looked super weird and it was more space than I needed. Any help would be super appreciated. I'm a but of a noob still.
<section id="projects">
<h2>My Work</h2>
<div class="container">
<div class="row justify-content-around">
<div class="col-lg-4 col-md-6 projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project"/>
<p class="project-title">CSS Technical Document</p>
</a>
</div>
<div class="col-lg-4 col-md-6 projects-grid">
<a href="https://briafly27.github.io/Javascript30DrumKit/" target="_blank">
<img class="project-image" src="Images/JavascriptDrumkit.png" alt="project"/>
<p class="project-title">Javascript Drumkit</p>
</a>
</div>
<div class="col-lg-4 col-md-6 projects-grid">
<a href="https://briafly27.github.io/FirstPersonalSite/" target="_blank">
<img class="project-image" src="Images/FirstPersonalSite.png" alt="project"/>
<p class="project-title">First Personal Site</p>
</a>
</div>
</div>
</div>
</section>
#projects {
background: #3F3F44;
color: #f7f7f7;
font-family: 'Raleway', sans-serif;
height: 100vh;
}
#projects h2 {
text-shadow: 1px 1px #fdcb9e;
text-align: center;
padding: 60px;
}
.projects-grid {
background-color: #fdcb9e;
box-shadow: 5px 8px black;
border-radius: 10px;
padding: 1% 0;
}
.projects-grid:hover {
background-color: #cceabb;
box-shadow: 7px 10px black;
}
.projects-grid a {
text-decoration: none;
color: #3f3f44;
text-shadow: 1px 1px #cceabb;
}
.project-image {
height: 100%;
max-height: 170px;
width: 100%;
max-width: 300px;
border-radius: 10px;
border: 2px solid #cceabb;
display: flex;
margin: 0 auto;
}
.project-image:hover {
border: 2px solid #fdcb9e;
}
.project-title {
font-size: 1.5rem;
font-weight: 700;
padding-top: 8px;
padding-bottom: 4px;
margin: 0;
text-align: center;
}
Bootstrap is adding the column guttering as a 15px padding, by styling the layout there, you are also styling the padding that is the guttering, hence the project grid 'cards' are touching.
For this, to keep the guttering and to ensure nice even columns, I would style a nested div instead.
<div class="col-md-4">
<div class="projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project" />
<p class="project-title">CSS Technical Document</p>
</a>
</div>
</div>
If the guttering is too large, you can change the sass variable (it's set to 30px by default) or you can use .no-gutters to remove all the guttering and add the padding manually to the nested divs.
<div class="row no-gutters">
<div class="col-md-4 p-2">
<div class="projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project" />
<p class="project-title">CSS Technical Document</p>
</a>
</div>
</div>
</div>
I've created this link on Codepen to try understanding better the problem so that we can help you better:
https://codepen.io/maricaldas/pen/ExPKNzM
<section id="projects">
<h2>My Work</h2>
<div class="container">
<div class="row justify-content-around">
<div class="col-lg-3 col-md-6 projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project" />
<p class="project-title">CSS Technical Document</p>
</a>
</div>
<div class="col-lg-3 col-md-6 projects-grid">
<a href="https://briafly27.github.io/Javascript30DrumKit/" target="_blank">
<img class="project-image" src="Images/JavascriptDrumkit.png" alt="project" />
<p class="project-title">Javascript Drumkit</p>
</a>
</div>
<div class="col-lg-3 col-md-6 projects-grid">
<a href="https://briafly27.github.io/FirstPersonalSite/" target="_blank">
<img class="project-image" src="Images/FirstPersonalSite.png" alt="project" />
<p class="project-title">First Personal Site</p>
</a>
</div>
</div>
</div>
</section>
Do you mean you want a space separating the project-grid columns?
If so, the first thing we need to consider is that when we use 3 columns taking 4 spaces each, we're using the full grid, which is 12, and that's why we can't see spaces around those col-lg-4 columns.
Can you please elaborate a little bit more on the result you want to achieve?
Maybe a way to add that space among the columns while using col-lg-4 is to overwrite the bootstrap pre-set width, which is 33.33%.
#media (min-width: 992px) {
.col-lg-4 {
-ms-flex: 0 0 32%;
flex: 0 0 32%;
max-width: 32%;
}
}

achieve 3 images exact size CSS

So I´m having trouble fitting 3 images in the same row ,
The thing is, that this images are not always the same so when I upload an image that its has a diferrent size everything moves., Any advise to achieve this ? thanks
HTML:
<div class="first-slot">
<div class="masonry-box post-media">
<img src="upload/'.$row['fotos'].'" alt="" class="img-fluid">
<div class="shadoweffect">
<div class="shadow-desc">
<div class="blog-meta">
<span class="bg-orange">'.$row['categoria'].'</span>
<h4>'.$row['titulo'].'</h4>
<small>'.$row['fecha'].'</small>
<small>'.$row['autor'].'</small>
</div>
</div>
</div>
</div>
</div>
CSS:
.first-slot {
float: left;
width: 65%;
height: 35%;
}
.last-slot,
.second-slot {
float: left;
width: 35%;
height: 28%;
}
Bootstrap
.img-fluid {
max-width: 100%;
height: auto;
}
I think this will solve your problem. You can use these class names and css in you code. Change image src locations according to your requirements. And change margin attribute in css according to your need.
PS: dnt forget to include bootstrap link in your project file
.imgItem{
display: inline-block;
margin: 10px;
}
.imgContainer{
display: flex;
}
<div class="row">
<div class="col imgContainer" >
<div class="col imgItem">
<img src="http://placehold.it/150x100" class="img-responsive
" alt="Responsive image" />
</div>
<div class="col imgItem">
<img src="http://placehold.it/150x100" class="img-responsive
" alt="Responsive image" />
</div>
<div class="col imgItem">
<img src="http://placehold.it/150x100" class="img-responsive
" alt="Responsive image" />
</div>
</div>
</div>

Masterializecss make background-color 100% of window when using container

I am using materializecss in my landing page. I have the page set up in a container (with the html {background-color: yellow}, but I want my background color in the second div to extend the full width of the window. How can I "extend past the bounds of the container"
Here is a jsfiddle
Right now it looks like this:
But I want it to look like this:
Here's my HTML
<div class="theme-landingpage-main">
<div class="container">
<div class="row">
<div class="col m12 l12 s12 layout-header">
<p class="headertitle">MELLOW<br /> MOMENT</p>
</div>
</div>
<div class="row layout-hero">
<div class="col s12 m6 l6 module-hero-picture-badge">
<img id="badge" src="app/assets/img/login/badge.png" alt="">
<img id="boxhero" src="app/assets/img/login/boxhero.png" alt="">
</div>
<div class="col s12 m6 l6 module-hero-text">
<img id="text-chill-banner" src="app/assets/img/login/banner.png" alt="">
<img id="talking-to-you" src="app/assets/img/login/text-talking-to-you.png" alt="">
<p>Take your life back. Breathe. Take stock of yourself. You need a break. Take one.<br>
Focus your mind. Relax your body.<br>
<p style="font-family: 'Raleway', sans-serif !important; font-weight: 400 !important; font-style: italic;">(and Take a Toke).</p>
</p>
<img id="text-retake-moment" src="app/assets/img/login/moment-text.png" alt="">
<img class="shop-button" src="app/assets/img/login/shopbut.png" alt="">
</div>
</div>
</div>
</div>
Here's the CSS
.theme-landingpage-main {
background-color: #FFD000;
//layouts and modules for landing page '/login'
.layout-header {
width: 100%;
height: 130px;
background-color: #FFD000;
.headertitle {
font-size: 40px !important;
position: relative;
font-family: 'Lobster Two', sans-serif !important;
font-weight: 400;
bottom: 25px;
}
}
.layout-hero { <---------------- this is the div in question
background-color: #F2F2F2;
.module-hero-picture-badge {
#badge {
position: relative;
width: 65%;
z-index: 2;
}
#boxhero {
width: 75%;
position: relative;
left: 17%;
bottom: 100px;
z-index: 1;
}
}
.module-hero-text{
p {
position: relative;
top: 20px;
right: 23px;
font-size: 20px !important;
text-align: center;
}
#text-chill-banner {
width: 128%;
position: relative;
right: 20%;
top: 50px;
z-index: 3;
}
#talking-to-you {
width: 480px;
position: relative;
top: 41px;
right: 45px;
}
#text-retake-moment {
width: 500px;
position: relative;
right: 12%;
}
}
}
}
What you need to do is close the initial .container (holding the logo) open a new div with a custom class enabling you to style it up (give it white background), open a new .container and have your hero content. When done, close .container again, close .white-bg, re-open .container and continue page.
.white-bg {
background-color: white;
}
<div class="theme-landingpage-main">
<div class="container">
<div class="row">
<div class="col m12 l12 s12 layout-header">
<p class="headertitle">MELLOW<br /> MOMENT</p>
</div>
</div>
</div> <!-- closed container -->
<div class="white-bg"> <!-- full width -->
<div class="container"> <!-- new container -->
<div class="row layout-hero">
<div class="col s12 m6 l6 module-hero-picture-badge">
<img id="badge" src="app/assets/img/login/badge.png" alt="">
<img id="boxhero" src="app/assets/img/login/boxhero.png" alt="">
</div>
<div class="col s12 m6 l6 module-hero-text">
<img id="text-chill-banner" src="app/assets/img/login/banner.png" alt="">
<img id="talking-to-you" src="app/assets/img/login/text-talking-to-you.png" alt="">
<p>Take your life back. Breathe. Take stock of yourself. You need a break. Take one.<br>
Focus your mind. Relax your body.<br></p>
<p style="font-family: 'Raleway', sans-serif !important; font-weight: 400 !important; font-style: italic;">(and Take a Toke).</p>
<img id="text-retake-moment" src="app/assets/img/login/moment-text.png" alt="">
<img class="shop-button" src="app/assets/img/login/shopbut.png" alt="">
</div>
</div>
</div> <!-- closed container -->
</div> <!-- closed white-bg -->
<div class="container">
Some other content, in container...
</div>
</div>
Side note: I noticed you have nested <p> tags. That's invalid HTML and will cause rendering problems. Most browsers will close the initial <p> tag before opening a new one, leaving your ending </p> orphan. Sometimes this doesn't have any visible effects, but it has the potential to break page or cause bugs that are hard to track/fix.
You can do it by using container for separate div
HTML
<div class="theme-landingpage-main">
<div class="container">
<div class="row">
<div class="col m12 l12 s12 layout-header">
<p class="headertitle">MELLOW<br /> MOMENT</p>
</div>
</div>
</div>
</div>
<div class="theme-landingpage-main white">
<div class="container">
<div class="row">
<div class="row layout-hero">
<div class="col s12 m12 l12 module-hero-picture-badge">
</div>
<div class="col s12 m12 l12 module-hero-text">
<p>Take your life back. Breathe. Take stock of yourself. Take one.<br>
Focus your mind. Relax your body.<br>
</p>
</div>
</div>
</div>
</div>
CSS
Add class white or background-color: #fff of this div class
.white {
background-color: #fff;
}
Demo
As per Grid explained in Materialize documentation. "It allows you to center your page content. The container class is set to ~70% of the window width. It helps you center and contain your page content. We use the container to contain our body content."
You need to divide the .container class withing the page. Where you want full width, just exclude that area from .container.
Example:
<div class="yellowBkg">
<header class="container">
Header Content
</header>
<div class="fullWidthGrayBkg">
<div class="container">
Because you need content within container.
</div>
<div>
<div class="container">
Further Content.
</div>
</div>
See your fiddle modified with solution: https://jsfiddle.net/avtarnanrey/ugr9qjp7/1/

Images do not align and are different heights

I have a problem with images displaying in different heights and text underneath not aligning.
this is the mark up, I have a six row containers to display 6 images
<div class="row">
<div class="posts">
<img src="images/bond.jpg" alt="quantum of solace">
<h3 class="title">Quantum of Solace</h3>
<p class="post-info">PG13 | 106min</p>
</div>
</div>
I am setting each post to 14% coz there are 6 of them allowing for 2.5% margin right. I tried to wrap image in a div and set that to overflow hidden, but didn't work.
.row {
width: 100%;
}
.posts {
width: 14%;
float: left;
margin-right: 2.5%;
}
.posts img {
width: 100%;
max-width: 100%;
border-radius: 0.5em;
}
If you can change the disposition of the nodes, you could align the text below the images using: display:table. See the next example:
.table {
display: table ;
}
.row {
display: table-row ;
}
.header, .title, .post-info {
display: table-cell ;
width: 14%;
padding: 0 1.25% 0.25% 1.25% ;
vertical-align: top ;
}
.header img {
max-width: 100%;
border-radius: 0.5em;
}
<div class="table">
<div class="row">
<div class="header">
<img src="https://upload.wikimedia.org/wikipedia/en/2/2d/Quantum_of_Solace_-_UK_cinema_poster.jpg" alt="quantum of solace">
</div>
<div class="header">
<img src="https://upload.wikimedia.org/wikipedia/en/6/66/E_t_the_extra_terrestrial_ver3.jpg" alt="E.T. the Extra-Terrestrial ">
</div>
<div class="header">
<img src="https://upload.wikimedia.org/wikipedia/en/a/a2/Star_Wars_The_Force_Awakens_Theatrical_Poster.jpg" alt="Star Wars VII">
</div>
<div class="header">
<img src="https://upload.wikimedia.org/wikipedia/en/8/8e/DisneyCheshireCat.jpg" alt="Alice in Wonderland">
</div>
<div class="header">
<img src="https://upload.wikimedia.org/wikipedia/en/6/6c/XFilesMoviePoster.jpg" alt="The X-Files">
</div>
<div class="header">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Poster_-_Gone_With_the_Wind_01.jpg/440px-Poster_-_Gone_With_the_Wind_01.jpg" alt="Gone with the Wind">
</div>
</div>
<div class="row">
<h4 class="title">Quantum of Solace</h4>
<h4 class="title">E.T. the Extra-Terrestrial </h4>
<h4 class="title">Star Wars: Episode VII The Force Awakens</h4>
<h4 class="title">Alice in Wonderland</h4>
<h4 class="title">The X-Files: Fight the Future</h4>
<h4 class="title">Gone with the Wind</h4>
</div>
<div class="row">
<p class="post-info">PG13 | 106min</p>
<p class="post-info">G | 115min</p>
<p class="post-info">PG13 | 136min</p>
<p class="post-info">G | 187min</p>
<p class="post-info">PG13 | 121min</p>
<p class="post-info">G | 238min</p>
</div>
</div>

Twitter Bootstrap Banner - How to render

This is probably a pretty basic question, but I have a banner with an image on the left and text on the right. Under the banner is just a block of color. When the page gets smaller, my expectation is that the bits in the banner would stack (maintaining the background color for both) and the block of color (class="blue-line") would fall beneath them.
Here is the mark-up:
<section>
<div class="row header">
<div class="col-sm-6">
<img src="../images/logo.png" height="100px" />
</div>
<div class="col-sm-6 title">
<h2>Some Title Text</h2>
</div>
</div>
<div class="row">
<div class="col-sm-12 blue-line"></div>
</div>
</section>
and the css
.header {
background-color: #F2EBCC;
border: 10px solid #F2EBCC;
height: 120px;
}
.row > .title {
text-align: right;
top: 45%;
}
Thanks in advance!
JSFiddle: http://jsfiddle.net/3n6Kd/
try this:
<section>
<div class="row header">
<div class="col-sm-6">
<img src="../images/logo.png" height="100px" />
</div>
<div class="col-sm-6 title">
<h2>Some Title Text</h2>
</div>
</div>
<div class="row">
<div class="col-sm-12 blue-line"></div>
</div>
and:
.header {
background-color: #F2EBCC;
height: 120px;
}
.title {
text-align: right;
display: block;
padding: 10px;
}
.blue-line {
margin-top:10px;
height: 15px;
background-color: blue;
}
the text go under the first column not the blue-line, but it seems to appear above the blue-line so try it in your computer because some time jsfiddle.net don't show code correctly.
hope it will help you.

Resources