Okay so i have a div with a container and 3 equal columns inside.Every column has a card with fixed height and width inside. However, below 1200px my design for a reason is breaking. What i mean is that when i resize to 1200px columns start to merge together and eventually in smaller sizes they tend to overlap the div and my footer. I know its complicated so here's some code.
----------HTML----------
<!-- 2nd card -->
<div class="col-md-4">
<div class="card">
<div class="cardoverlay">
</div>
</div>
</div>
<!-- 3rd card -->
<div class="col-md-4">
<div class="card">
<div class="cardoverlay">
</div>
</div>
</div>
</div>
</div>
</div>
-----------CSS-----------
.categories {
background-color: #e1e1e1;
height: 800px;
}
.card {
width: 353px;
height: 662px;
-webkit-border-radius: 5px/7px;
-moz-border-radius: 5px/7px;
border-radius: 8px/10px;
background-color: #fff;
-webkit-box-shadow: 0 2px #b8b3b3;
-moz-box-shadow: 0 2px #b8b3b3;
box-shadow: 3px #b8b3b3;
margin-top: 50px;
}
.cardoverlay {
width: 353px;
height: 202px;
-webkit-border-radius: 5px 5px 0 0/10px 10px 0 0;
-moz-border-radius: 5px 5px 0 0/10px 10px 0 0;
border-radius: 5px 5px 0 0/10px 10px 0 0 #f1f1f1;
background-color: #f9f9f9;
-webkit-box-shadow: 0 3px #f1f1f1;
-moz-box-shadow: 0 3px #f1f1f1;
box-shadow: 0 3px #f1f1f1;
The columns at this point are getting merged.
http://imgur.com/dEQzLjb
P.S i am using container instead of container-fluid so i can get the columns the one next to each other.
You are using a specific width rule, meaning the divs will always stay at those sizes. When the browser is re-sized smaller they will run over each other.
If you use a percentage based layout % this will not happen as they will scale relative to the container size.
.card, .cardoverlay {
width: 33%;
}
Related
I am trying to make a layout where divs fall into a columns each with width 250px, so wider screens have more columns.
I also want the gap between the columns to remain the same in this case 5px. The problem is when I readjust the width of the screen the gap changes in size (although the columns remain 250px and a new one is added or removed when there is enough extra space).
The extra space when I expand the screen to when a new column is rendered should go on either side of the column container;
My container is the following:
#my-pages-list-holder-new-fu{
overflow-y: scroll;
column-width: 250px;
justify-content: center;
column-gap: 5px;
}
/*my blocks which fall into the columns have this code:*/
.post-wrapper-tue{
height: fit-content;
width:250px;
margin-bottom: 10px;
-webkit-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
-moz-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
}
Try this:
<style>
#my-pages-list-holder-new-fu{
overflow-y: scroll;
column-width: 250px;
justify-content: center;
column-gap: 2vw;
}
/* my blocks which fall into the columns have this code: */
.post-wrapper-tue{
height: fit-content;
width:250px;
margin-bottom: 10px;
-webkit-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
-moz-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
}
</style>
<div id="my-pages-list-holder-new-fu">
<div class="post-wrapper-tue">
<text>Ze Block</text>
</div>
<div class="post-wrapper-tue">
<text>Ze Other Block</text>
</div>
<div class="post-wrapper-tue">
<text>Ze Other Other Block</text>
</div>
</div>
If this doesn't work please keep in mind I could not properly test it.
I'm trying center a Block grid inside of a div, but when I apply my CSS class the Block grid is not affected.
I have this visually (The outline is made with a Firefox extension):
Block grid alligment
and I wanna make look like this:
Block grid alligment
As you can see, I need align te Block grid content and the div content also, but I don't know how I can do it.
This is my current code:
<div class="sitios-amigos">
<div class="wrap row small-up-1 medium-up-4">
<div class="column column-block tarjeta-material">
<a src="http://www.conacyt.gob.mx/" target="_blank"><img alt="Página web Conacyt" src="img/conacyt.png"/></a>
</div>
<div class="column column-block tarjeta-material">
<a href="http://www.concytep.pue.gob.mx/" target="_blank">
<img alt="Página web de Concytep" src="img/concytep.png"></a>
</div>
<div class="column column-block tarjeta-material">
<a href="http://www.viep.buap.mx/" target="_blank">
<img alt="Página web VIEP BUAP" src="img/VIEP.png"></a>
</div>
</div>
</div>
CSS:
.sitios-amigos{
background: red;
max-width:11000px;
width: 100%;
margin: 0 auto;
}
.wrap{
width:90%;
max-width:11000px;
margin: 0 auto;
}
.tarjeta-material {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
margin: 15px 10px;
text-align:center;
}
.tarjeta-material:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
.tarjeta-material {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
margin: 15px 10px;
text-align:center;
}
.tarjeta-material:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
If the div you want to align center is a child of another div. Here is what you can do.
.parent-div {
text-align: center;
.child-div {
display: inline-block;
}
You can also try without referencing the parent div.
.child-div {
margin-left: auto;
margin-right: auto;
}
center it in the absolute middle try:
.parent-div {
position: relative;
.child-div {
position: absolute;
top: 50%;
/* this will put the left edge at 50%. not the image */
left: 50%;
/* do a negative margin-left of half the width of your block so you have to find that.*/
margin-left: -halfthewidth;
margin-top: -halfthelength;
}
have you tried using bootstrap grid system ? they have so much sample and much easier to use ..
I have several divs side by side floating on left and spread on multiple lines:
<!doctype html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
width: 100%;
}
.elem {
height: 300px;
width: 150px;
background-color: rgba(230,230,230,1);
-webkit-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.3);
box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.3);
margin: 20px;
padding: 10px;
float: left;
transition: all 0.5s ease;
}
.elem:hover {
-webkit-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.7);
-moz-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.7);
box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.7);
margin: 10px;
padding: 20px;
background-color: rgba(130,230,230,1);
}
.w140 { width: 140px; }
.w70 { width: 70px; }
.w200 { width: 200px; }
.w50 { width: 50px; }
.grid {
width: 100%;
}
</style>
</head>
<body>
<div class="grid">
<div class="elem w140">elem1</div>
<div class="elem">elem2</div>
<div class="elem w200">elem3</div>
<div class="elem w50">elem4</div>
<div class="elem">elem5</div>
<div class="elem">elem6</div>
<div class="elem w70">elem7</div>
<div class="elem w50">elem8</div>
<div class="elem">elem9</div>
<div class="elem w200">elem10</div>
</div>
</body>
</html>
This works perfectly fine on firefox. But on Chrome (Version 55.0.2883.87 to be exact) when hovering some elements (for example the last one before a "line break"), the layout will get messed up during the transition duration.
How do I prevent this?
Fiddle at http://jsfiddle.net/d6rs6gsq/
I found a workaround referring to Animating margins and padding with CSS Transition causes jumpy animation
use css scale transform instead of manipulating the padding and margin values.
.elem {
height: 300px;
width: 150px;
background-color: rgba(230,230,230,1);
-webkit-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.3);
box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.3);
margin: 20px;
padding: 10px;
float: left;
transform:scale(1);
transition: all 0.5s ease;
}
.elem:hover {
-webkit-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.7);
-moz-box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.7);
box-shadow: 10px 10px 38px 0px rgba(0,0,0,0.7);
transform:scale(1.1);
background-color: rgba(130,230,230,1);
}
http://jsfiddle.net/d6rs6gsq/2/
Hope it solves
It happens when the last element in the row animates with the one before it. Since the animation is ease and not linear, there are points during the combined animations when they create "corners" into which elements from next row are floating.
There are multiple ways to get rid of this unwanted effect. First, you shouldn't be animating padding or margin for grid elements. The rule of thumb in animation is: Never animate the space the element occupies, but only the element's rendered image. You want to use transforms or position:relative and top|right|bottom|left as none of these modify the space an element takes in document's flow.
However, the simplest solution in your case would be remove float:left from your .elem and apply: display:flex;flex-wrap:wrap; to your grid. The flex grid is smart enough to not break rows below based on inconsistencies in height of elements in previous row. It's one of the many advantages of the flexbox model over the box model.
Updated fiddle: http://jsfiddle.net/websiter/d6rs6gsq/3/
I am using a framework which is generating 3 div tags. These three div tags cover one row on the page.
It looks like the first div covers 25% of the row and 2 div covers 25% of the row and the third div covers 50% of the row. I have access to the css class which third div is utilizing which looks like this:
.dataTables_processing {
position: fixed;
top: 50%;
left: 50%;
min-width: 125px;
margin-left: 0;
padding: 7px;
text-align: center;
color: #333;
font-size: 13px;
border: 1px solid #ddd;
background-color: #eee;
vertical-align: middle;
-webkit-box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
}
Is there any way to modify this class to make it cover the entire row?
Try adding :
position:absolute;
left:0;
width:100%;
Try this
display: block;
width: 100%;
min-width: 100% !important;
If you are trying to have some div that each one takes a row and you want them to align vertically, use bootstrap and you can do something like this:
<div style='display: flex; flex-direction: column;'>
<div class='row'> my content to take a row </div>
<div class='row'> my content to take second row </div>
<div class='row'> my content to take a third</div>
</div>
Hope it helps.
I'm trying to display an inset shadow on two elements and overlay them so they look like well with tab. Everything looks great except for one corner where I cannot figure out how to make it look smooth. (highlighted with yellow).
JsFiddle for test
this is my html:
<div class="container">
<div class="outerWell">
<div class="well" style="padding-top:15px">
text
</div>
</div>
<div class="well" style="margin-top:40px">
test
</div>
</div>
and then I have css that creates shadow and hides one side of shadow with overflow:hidden
(.well class is taken from bootstrap)
.well {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
overflow:hidden;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-moz-box-shadow: inset 0 0 5px 1px #888;
-webkit-box-shadow: inset 0 0 5px 1px #888;
box-shadow: inset 0 0 5px 1px #888;
}
.outerWell {
width: 200px;
overflow: hidden;
padding-bottom: 10px;
height: 35px;
margin-top: -40px;
position:absolute;
}
Is there an easy way to fix my issue, or maybe a better way to do what I'm trying to achieve?
You could probably pull this off with some creative use of pseudo elements. Have a look at this post on CSS-Tricks.