I try to implement this graphic with HTML, CSS using flexbox:
Now, I have trouble with the left part. I don't know how to implement this -90 degrees rotated element. The right part (all elements that are horizontally aligned) is not the problem.
Here is what I have so far:
.container {
max-width: 1176px;
width: 100%!important;
margin: 0 auto!important;
float: none!important;
z-index: 1;
}
.pt {
padding-top: 3.5rem;
/* 56px */
}
.pb {
padding-bottom: 3rem;
/* 48px */
}
.ptms {
padding-top: 1.5rem;
/* 24px */
}
.full-width {
width: 100%;
padding: 0 1.5rem;
}
.three-col {
width: 33.3333334%;
padding: 0 1.5rem;
}
.platform-container,
.platform-card-container {
display: flex;
}
.platform-card-container .three-col,
.platform-card-container .full-width {
padding: 0 .75rem;
}
.platform-card-container a {
text-decoration: none;
}
.platform-card,
.platform-card-first {
border-radius: .5rem;
box-shadow: 0 .25rem .75rem 0 rgba(27, 27, 27, 0.24);
display: flex;
height: 100%;
}
.platform-card {
align-items: center;
}
.platform-card-first {
}
.platform-card-icon {
padding: .75rem;
border-radius: 50%;
background-color: #f5f5f5;
width: 3.5rem;
height: 3.5rem;
min-width: 3.5rem;
}
.platform-card-text {
margin-left: 1rem;
}
.platform-card-text-title {
margin-bottom: .5rem;
color: #1b1b1b;
}
.platform-card-text-desc {
color: #007095;
}
<div class="container platform-container">
<div>
<div class="pt platform-card-container">
<div class="full-width">
<a href="">
<div class="platform-card-first">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-technology-3d-printing-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Open Architecture</h4>
<div class="platform-card-text-desc">Extend systems as required</div>
</div>
</div>
</a>
</div>
</div>
</div>
<div>
<div class="pt platform-card-container">
<div class="three-col">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-design-ruler-triangle-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">User Interface</h4>
<div class="platform-card-text-desc">Modern front-end technologies</div>
</div>
</div>
</a>
</div>
<div class="three-col">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-mobile-phone-location-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Intelligent Mobility</h4>
<div class="platform-card-text-desc">Mobile and offline access</div>
</div>
</div>
</a>
</div>
<div class="three-col">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-network-monitor-team-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Social Collaboration</h4>
<div class="platform-card-text-desc">Efficient teamwork</div>
</div>
</div>
</a>
</div>
</div>
<div class="ptms platform-card-container">
<div class="full-width">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-toys-lego-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Low-Code Suppport</h4>
<div class="platform-card-text-desc">Processes without programming</div>
</div>
</div>
</a>
</div>
</div>
<div class="ptms platform-card-container">
<div class="three-col">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-multimedia-shuffle-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Business Rule Engine</h4>
<div class="platform-card-text-desc">Intelligent decision making</div>
</div>
</div>
</a>
</div>
<div class="three-col">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-programming-module-puzzle-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Integration</h4>
<div class="platform-card-text-desc">Standard connectors and more</div>
</div>
</div>
</a>
</div>
<div class="three-col">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-transportation-road-sign-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Adaptive Case Management</h4>
<div class="platform-card-text-desc">Making processes flexible</div>
</div>
</div>
</a>
</div>
</div>
<div class="ptms platform-card-container">
<div class="full-width">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-interface-settings-cog-double-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Process Engine</h4>
<div class="platform-card-text-desc">Powerful process automation</div>
</div>
</div>
</a>
</div>
</div>
<div class="ptms platform-card-container">
<div class="full-width">
<a href="">
<div class="platform-card">
<div class="platform-card-icon">
<img src="img/icons/axonivy-website-icon-work-presentation-projector-screen-darkblue.svg">
</div>
<div class="platform-card-text">
<h4 class="platform-card-text-title">Modern Runtime Platform</h4>
<div class="platform-card-text-desc">Environment with container support</div>
</div>
</div>
</a>
</div>
</div>
</div>
Does anyone have a hint on how I should proceed?
I believe these styles are what you want:
text-align: right;
writing-mode: vertical-rl;
transform: rotate(180deg);
text-orientation: mixed;
https://jsfiddle.net/aycq2v8u/
edit: I noticed that the height still wasn't right. (BTW, display:grid makes this sort of thing easier). here's a revision with that fixed as well. although, this does require either ridiculous looking selectors or changes to the html, which I have done here: https://jsfiddle.net/rxgbo4a9/
changes required:
the card container of the first card (that needs to be full height) needs to be different. since it is on the side and generally different content, I marked it as an aside:
<aside class="pt platform-card-container">
then, with that, using minimal changes to your css we get the desired result:
aside.platform-card-container {
height:100%
}
aside.platform-card-container a {
display: flex;
height: 100%
}
note that specifying height instead of using flexbox is not ideal. however, since all your code makes the same mistake, I think you minimize technical debt to keep all the problems of the same type .. ie, keep using height until you are ready to remove it generally.
Related
I am trying to code a page where each section fills the whole page. And I am also trying to center vertically and horizontally the divs in each section.
I don't know if it's possible, if you guys can enlighten me it would be great.
I also would like to know if it's possible that, when I scroll it automatically goes to the next section. I don't know if it's clear enough to understand.
Here's the CSS :
.presta .container {
width: 100%;
position: relative;
}
.presta .h1 {
font-size: 80px;
font-weight: bold;
}
.presta card {
padding: 30px;
margin: 0 auto;
}
.logoPresta:hover {
transition: transform 0.3s ease-in;
transform: translateY(-10px);
}
.prestaShow {
text-align: center;
}
.wrapper {
min-height: 100%;
}
<div class="navbar ">
<div class="container flex">
<div class="logo" data-aos="fade-right">
<img src="images/linko_bg_transp.png" alt="" />
</div>
<nav data-aos="fade-in">
<ul>
<li>Accueil</li>
<li>Présentation</li>
<li>Nos Prestations</li>
<li>Nous contacter</li>
</ul>
</nav>
</div>
</div>
<section class="presta bg-light wrapper">
<div class="container">
<div class="text-center">
<h1>Nos domaines d'expertises</h1>
</div>
<div class="grid grid-4">
<div class="logoPresta card">
<img src="images/1.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/2.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/3.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/4.jpg" alt="">
</div>
</div>
</div>
</section>
<section class="prestaShow wrapper">
<div class="container info">
<div class="text-center">
<h2>Informatique</h2>
</div>
<div class="textePresta card">
Conception & développement d'applications web
</div>
<div class="textePresta card">
Création & amélioration de bases de données
</div>
<div class="textePresta card">
Déploiement d'infrastructures réseaux
</div>
</div>
</section>
Here are the images of the page :
You can resize section to full page height by changing 100% to 100vh
Also, take a look at CSS section to see how to center wrappers' content (expand Code snippet to see differences).
UPD:
.snap-wrapper will help you to scroll full sections, take a look at Code snippet on full-screen.
.presta .container {
width: 100%;
position: relative;
}
.presta .h1 {
font-size: 80px;
font-weight: bold;
}
.presta card {
padding: 30px;
margin: 0 auto;
}
.logoPresta:hover {
transition: transform 0.3s ease-in;
transform: translateY(-10px);
}
.prestaShow {
text-align: center;
}
.wrapper {
/* centering wrapper content */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
}
/* use .snap-wrapper to scroll page by full sections */
.snap-wrapper {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
scroll-snap-type: y mandatory;
overflow: auto;
height: 100vh;
}
.snap-wrapper > .wrapper {
scroll-snap-align: center;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="navbar ">
<div class="container flex">
<div class="logo" data-aos="fade-right">
<img src="images/linko_bg_transp.png" alt="" />
</div>
<nav data-aos="fade-in">
<ul>
<li>Accueil</li>
<li>Présentation</li>
<li>Nos Prestations</li>
<li>Nous contacter</li>
</ul>
</nav>
</div>
</div>
<div class="snap-wrapper">
<section class="presta bg-light wrapper">
<div class="container">
<div class="text-center">
<h1>Nos domaines d'expertises</h1>
</div>
<div class="grid grid-4">
<div class="logoPresta card">
<img src="images/1.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/2.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/3.jpg" alt="">
</div>
<div class="logoPresta card">
<img src="images/4.jpg" alt="">
</div>
</div>
</div>
</section>
<section class="prestaShow wrapper">
<div class="container info">
<div class="text-center">
<h2>Informatique</h2>
</div>
<div class="textePresta card">
Conception & développement d'applications web
</div>
<div class="textePresta card">
Création & amélioration de bases de données
</div>
<div class="textePresta card">
Déploiement d'infrastructures réseaux
</div>
</div>
</section>
</div>
I want to acheive this design any next category will automatically adjust to the previous div. Every category have not specific product but need to just after the previous product like we use float left or display-flex But don't want to create multiple css for responsive. Because it has more than 25 categories. `
.offerpage .product-box {
margin: 0 5px;
}
.categoryProductsWrap{
width: 100%;
}
.product-img{
width: 100%;
}
.categoryProductsWrap .categoryProducts {
display: flex;
flex-wrap: wrap;
width: 100%;
}
.categoryProductsWrap .categoryProducts .product-box {
margin-bottom: 10px;
float: left;
}
.offerpage .categoryName {
color: #161719;
font-size: 24px;
font-weight: bold;
margin-bottom: 0.5em;
border-bottom: solid 1px #dddddd;
padding-bottom: 0.125em;
}
.img-box{
position: relative;
padding-top: 124%;
display: inline-block;
width: 100%;
vertical-align: top;
}
.product-box .product-img{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
.txt-content {
overflow: hidden;
position: relative;
}
.img-box{
position: relative;
padding-top: 124%;
display: inline-block;
width: 100%;
vertical-align: top;
}
.offerpage{
display: flex;
flex-wrap: wrap;
}
.categoryProductsWrap .categoryProducts .product-box{
width: 33.333%
}
#media (min-width: 1200px){
.categoryProductsWrap.cooling_fan {
width: 50%;
}
.categoryProductsWrap.accessories {
width: 50%;
}
}
#media (min-width: 1440px){
.categoryProductsWrap.accessories .categoryProducts .product-box,
.categoryProductsWrap.cooling_fan .categoryProducts .product-box {
width: calc(50% - 10px);
}
}
<div class="offerpage">
<div class="categoryProductsWrap accessories">
<div class="categoryName">Accessories</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="categoryProductsWrap cooling_fan">
<div class="categoryName">Cooling Fan</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="categoryProductsWrap asus">
<div class="categoryName">Asus</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="categoryProductsWrap audio">
<div class="categoryName">Audio Device</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`
If you want to use CSS grid, there no big difficulties simply check the documentation to understand the main CSS properties you need to add.
Also check this guide on CSS grid to undertand more and see examples.
Quick help
If I understand correctly you want 3 items max per row, to do that you will need to set:
grid-template-columns: repeat(3, 1fr);
The equivalent to flex-direction: row; is grid-auto-flow: row;
You will I presume also need a gap (spacing between items), something like that:
gap: 10px;
So a good starting point will be:
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-auto-flow: row;
gap: 10px;
I leave you do the rest according to your needs.
See Umbrella image in images:
Full-size window:
.
Reduced (ideal placement):
I would like to have my umbrella image in the centre of the screen no matter the size of the window.
It works from the point where the window shrinks and works in mobile view too.
I've tried various methods but it doesn't seem to be working, any tips would be greatly appreciated.
Here is my code:
HTML
<div class="wrapper">
<div class="page2">
<h2>Blog</h2>
<div class="wrap">
<div class="card">
<a href="welcome.html">
<img class="card-img" src="str3.jpg">
</a>
<div class="card-text">
<h3>Welcome</h3>
<p>Website Launch and my First Project</p>
</div>
</div>
<div class="card">
<a href="blog.html">
<img class="card-img" src="steve_roe_kyoto.jpg">
</a>
<div class="card-text">
<h3> Kyoto</h3>
<p>My Recent Trip</p>
</div>
</div>
<div class="card">
<a href="best.html">
<img class="card-img" src="str4.jpg">
</a>
<div class="card-text">
<h3>Best of 2018</h3>
<p>Neon Goodness from Last Year</p>
</div>
</div>
</div>
<div class="page3">
<footer>
<div class="umbrella_icon">
<img src="umbrella-02.png">
</div>
<div class="logo_footer">Steve Roe</div>
<div class="footer_menu">
<ul class="ul_footer">
<li>Work With Me</li>
<li>
Contact</li>
</ul>
</div>
</footer>
</div>
</div>
</div>
CSS
.page2{
width: 100%;
margin: 0 auto;
margin-top: 20px;
height: 100%;
}
//cards
.wrap{
width:960px;
margin:auto;
margin-top: 100px;
}
.card{
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.15);
transition: 0.4s;
width: 300px;
text-align: center;
font-size: 16px;
float:left;
margin:10px;
text-decoration: none;
}
.page3{
margin: 20px;
margin-top: 20px;
height: 30%;
}
.umbrella_icon {
text-align: center;
}
.footer {
z-index: 1000;
width: 960px;
margin: 0 auto;
}
Use dispaly:flex to .wrap
See working code
.page2{
width: 100%;
margin: 0 auto;
margin-top: 20px;
height: 100%;
}
.wrap{
margin: auto;
margin-top: 100px;
display: flex;
}
.card{
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.15);
transition: 0.4s;
width: 300px;
text-align: center;
font-size: 16px;
float:left;
margin:10px;
text-decoration: none;
}
.page3{
margin: 20px;
margin-top: 20px;
height: 30%;
}
.umbrella_icon {
text-align: center;
}
.footer {
z-index: 1000;
width: 960px;
margin: 0 auto;
}
<div class="wrapper">
<div class="page2">
<h2>Blog</h2>
<div class="wrap">
<div class="card">
<a href="welcome.html">
<img class="card-img" src="str3.jpg">
</a>
<div class="card-text">
<h3>Welcome</h3>
<p>Website Launch and my First Project</p>
</div>
</div>
<div class="card">
<a href="blog.html">
<img class="card-img" src="steve_roe_kyoto.jpg">
</a>
<div class="card-text">
<h3> Kyoto</h3>
<p>My Recent Trip</p>
</div>
</div>
<div class="card">
<a href="best.html">
<img class="card-img" src="str4.jpg">
</a>
<div class="card-text">
<h3>Best of 2018</h3>
<p>Neon Goodness from Last Year</p>
</div>
</div>
</div>
<div class="page3">
<footer>
<div class="umbrella_icon">
<img src="umbrella-02.png" alt="umbrella">
</div>
<div class="logo_footer">Steve Roe</div>
<div class="footer_menu">
<ul class="ul_footer">
<li>Work With Me</li>
<li>
Contact</li>
</ul>
</div>
</footer>
</div>
</div>
</div>
End The page 2 div before starting page 3 div.
Change the page3 css to
.page3{
margin: 50vh 50vw;
}
<h2>Blog</h2>
<div class="wrap">
<div class="card">
<a href="welcome.html">
<img class="card-img" src="str3.jpg">
</a>
<div class="card-text">
<h3>Welcome</h3>
<p>Website Launch and my First Project</p>
</div>
</div>
<div class="card">
<a href="blog.html">
<img class="card-img" src="steve_roe_kyoto.jpg">
</a>
<div class="card-text">
<h3> Kyoto</h3>
<p>My Recent Trip</p>
</div>
</div>
<div class="card">
<a href="best.html">
<img class="card-img" src="str4.jpg">
</a>
<div class="card-text">
<h3>Best of 2018</h3>
<p>Neon Goodness from Last Year</p>
</div>
</div>
</div>
</div>
<div class="page3">
<footer>
<div class="umbrella_icon">
<img src="umbrella-02.png" alt="umbrella Here">
</div>
<div class="logo_footer">Steve Roe</div>
<div class="footer_menu">
<ul class="ul_footer">
<li>Work With Me</li>
<li>
Contact</li>
</ul>
</div>
</footer>
</div>
Use flex for .wrap like this :
.wrap{
width:960px;
margin:auto;
margin-top: 100px;
display: flex;
justify-content: center;
}
this code make image in center horizontally.
I have a grid I have built out of flex boxes. Some of the grid is made of squares, with two rectangles. I can't seem to get the boxes to align correctly, using flexbox with flex-grow, or manually setting the box heights. The goal is to have them all line up with equal margins between the entire grid. Here is the grid code:
.project-grid { height: 1400px; padding: 80px 20px; }
.project-grid .column { width:33.33%; margin-left:10px; flex-direction:column; margin-top:-10px; }
.project-grid .column:first-child { margin-left:0; }
.project-grid .column .box {
margin-top:10px;
background-color:blue;
height: 400px;
background-size:cover;
background-repeat: no-repeat;}
.project-grid .column .box.tall { height:800px; }
.project-grid .column a .box > p {
font-family: $lato;
color: $white;
font-size: 24px;}
.flex { display:flex;}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');" <a href="/projects">
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
CSS
For easy viewing, here is a codepen I've made: https://codepen.io/bsquared/pen/zdPqPJ
As commented, if you involved <a> in your flex layout and also to draw the background, you can achieve the visual you look for.
a {
/*with no fix height so it can be spread evenly if needed*/
background: blue;
/* draw bg here it will include children area and further if needed to even the visual */
margin: 10px;
/* set margins here */
color: white;
}
/* flex layout and sizing */
.flex,
a {
display: flex;
}
.column,
a {
flex-direction: column;
flex: 1;/* make fill entire space left if any */
}
.box {
height: 400px;
}
.tall {
height: 800px;
}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');"><!-- background-image is to be send & set to the parent A -->
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
If you want to keep heights, then you need to mind the amounts of margins all together with eights of elements in each column :
example
.project-grid { height: 1400px; padding: 80px 20px; }
.project-grid .column { width:33.33%; margin-left:10px; flex-direction:column; margin-top:-10px; }
.project-grid .column:first-child { margin-left:0; }
.project-grid .column .box {
margin-top:10px;
background-color:blue;
height: 400px;
background-size:cover;
background-repeat: no-repeat;}
.project-grid .column .box.tall { height:824px; }
.project-grid .column a .box > p {
font-family: $lato;
color: $white;
font-size: 24px;}
.flex { display:flex;}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');" >
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
CSS
The p tags, which has margins top and bottom by defaults, are pushing the boxes up. You have to use overflow: auto; on the parent div to prevent it from happening.
.project-grid .column .box {
// ...
overflow: auto;
}
Full working code:
.project-grid {
height: 1400px;
padding: 80px 20px;
}
.project-grid .column {
width: 33.33%;
margin-left: 10px;
flex-direction: column;
margin-top: -10px;
}
.project-grid .column:first-child {
margin-left: 0;
}
.project-grid .column .box {
margin-top: 10px;
background-color: blue;
height: 400px;
background-size: cover;
background-repeat: no-repeat;
overflow: auto;
}
.project-grid .column .box.tall {
height: 800px;
}
.project-grid .column a .box>p {
font-family: $lato;
color: $white;
font-size: 24px;
}
.flex {
display: flex;
}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');" <a href="/projects">
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
CSS
I have dynamic div boxes created in a website, I want to have 4 boxes in each row using bootstrap, that's working, but each box has some text at the bottom, the problem is that when the text is too long and it creates a new line, the div expands but the box underneath this div moves to the right, instead of moving all the row underneath down.
This is the html:
<div class="row">
<div ng-repeat=""class="col-sm-3 album-art"> //loop to create the boxes
<div class="thumb">
<div class="box">
<span class="play" ng-click="">►</span>
<div class="overlay"></div>
</div>
<img src= height="200" width="200">
<p>text</p>
<p><i>text</i></p>
</div>
</div>
And this is the css I have:
.album-art{
padding-bottom: 20px;
padding-top: 20px;
margin-bottom: 10px;
}
.thumb {
position: relative;
}
.thumb .box {
position: absolute;
top: 0;
display: block;
width: 200px;
height: 200px;
text-align: center;
text-decoration: none;
cursor: pointer;
}
Basically what I'd need is that when the text overflows and creates a new line, the row below the current row moves down and not move every element to the right.The problem seems to be in the "album-art" class, since I removed all the other classes and the problem still there.
thanks
EDIT: I've added images for a better explanation
This is when everything is normal
But when the text is longer
EDIT2: I put an example here: jsfiddle.net/qgo7a701 you might have to expand the result area to the left in order to see 4 squares per row
I don't understand you question very well , but in bootstrap the row divided to 12 cell, and you can define divs in row with different sizes.and you can use col-[xl,lg,md,sm,xs]-[1 to 12] classes for that. you can look to this link :
http://getbootstrap.com/examples/grid/
for you example below i have tried to make two row with two boxes and i only break the text to prevent it to overflow to next div
.album-art{
padding-bottom: 20px;
padding-top: 20px;
margin-bottom: 10px;
}
p{
word-break: break-all;
}
.thumb {
position: relative;
}
.thumb .box {
position: absolute;
top: 0;
display: block;
width: 200px;
height: 200px;
text-align: center;
text-decoration: none;
cursor: pointer;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="row">
<div ng-repeat=""class="col-sm-3 album-art">
//loop to create the boxes
<div class="thumb">
<div class="box">
<span class="play" ng-click="">►</span>
<div class="overlay">
</div>
</div>
<img src= height="200" width="200"/>
<p style="">text helooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo</p>
<p><i>text</i></p>
</div>
</div>
<div ng-repeat=""class="col-sm-3 album-art">
//loop to create the boxes
<div class="thumb">
<div class="box">
<span class="play" ng-click="">►</span>
<div class="overlay">
</div>
</div>
<img src= height="200" width="200"/>
<p style="">text heloooooooooooooooooooooooooooooooooooooooooo</p>
<p><i>text fffffffffffffffffffffffffffffffffffffffffffffffddddddddddddddsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdddddddddddddddddddddddddddddddddddd fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff</i></p>
</div>
</div>
</div>
<div class="row">
<div ng-repeat=""class="col-sm-3 album-art">
//loop to create the boxes
<div class="thumb">
<div class="box">
<span class="play" ng-click="">►</span>
<div class="overlay">
</div>
</div>
<img src= height="200" width="200"/>
<p style="">text helooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo</p>
<p><i>text</i></p>
</div>
</div>
<div ng-repeat=""class="col-sm-3 album-art">
//loop to create the boxes
<div class="thumb">
<div class="box">
<span class="play" ng-click="">►</span>
<div class="overlay">
</div>
</div>
<img src= height="200" width="200"/>
<p style="">text helooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo</p>
<p><i>text</i></p>
</div>
</div>
</div>
I tested what you did and it was working as intended. You used 1 row for the complete collection of cols, so they behaved as intended. To change that, you must force a grouping of cols and you can do it like this:
(Resume here:
- Add div class="col-sm-12" style="display: table" and close it after 4 of your "col-sm-3 divs". Add another one for the rest of the "col-sm-3 divs". Everything should be inside the div class="row". (I would have used two rows every 4 "col-sm-3 divs" but, is your code).
- Change the "style" into a css, include it in your stylesheet, add the class to the div. End.
.album-art {
padding-bottom: 20px;
padding-top: 20px;
margin-bottom: 10px;
}
.thumb {
position: relative;
}
.thumb .box {
position: absolute;
top: 0;
display: block;
width: 200px;
height: 200px;
text-align: center;
text-decoration: none;
cursor: pointer;
}
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<style>
.album-art {
padding-bottom: 20px;
padding-top: 20px;
margin-bottom: 10px;
}
.thumb {
position: relative;
}
.thumb .box {
position: absolute;
top: 0;
display: block;
width: 200px;
height: 200px;
text-align: center;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="row">
<div class="col-sm-12" style="display: table;">
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">tedddddddxxxx ewhuiofhew hfiuhiufw shidfshksdhxfffffffffffffxxxxxddddddxt</p>
</div>
</div>
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
</div>
<div class="col-sm-12" style="display: table;">
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
<div class="col-sm-3" style="padding-bottom: 20px; padding-top: 20px">
<div class="thumb">
<div class="box">
<span class="play"></span>
<div class="overlay"></div>
</div>
<img src="#" height="50" width="50" />
<p style="color: black">text</p>
</div>
</div>
</div>
</div>
</body>
</html>