Overflow doesn't work properly with pure CSS cubes - html

I have been trying to make a background with pure CSS (Using CSS triangles with the help of border property) and I was successful so far. But there's an overflow issue that's destroying whole thing.
as shown in above image; I want 3rd cube exactly on the right side of 2nd cube (half hidden).
CSS:
.cube {
float: left;
height:239px;
width:200px;
}
.cube .top {
}
.cube .top .high{
width: 0;
height: 0;
border-bottom: 60px solid #46B535;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
}
.cube .top .low {
width: 0;
height: 0;
border-top: 60px solid #46B535;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
}
.cube .left {
float: left;
position: relative;
top: -60.7px;
}
.cube .left .high {
width: 0;
height: 0;
border-bottom: 60px solid #59BE32;
border-right: 100px solid transparent;
}
.cube .left .mid {
height: 60px;
width: 100px;
background: #59BE32;
}
.cube .left .low {
width: 0;
height: 0;
border-top: 60px solid #59BE32;
border-left: 100px solid transparent;
}
.cube .right {
float: left;
position: relative;
top: -60.7px;
}
.cube .right .light .up {
width: 0;
height: 0;
border-bottom: 60px solid #27B138;
border-left: 100px solid transparent;
}
.cube .right .light .down {
width: 0;
height: 0;
border-top: 60px solid #27B138;
border-left: 100px solid transparent;
}
.cube .right .dark {
position: relative;
top: -61px;
}
.cube .right .dark .up {
width: 0;
height: 0;
border-bottom: 60px solid #00AA3A;
border-right: 100px solid transparent;
}
.cube .right .dark .down {
width: 0;
height: 0;
border-top: 60px solid #00AA3A;
border-right: 100px solid transparent;
}
.clear {
clear: both;
}
.even {
clear: both;
overflow:hidden;
height:36%;
}
HTML:
<section class="even">
<section class="cube">
<div class="top">
<div class="high"></div>
<div class="low"></div>
</div>
<div class="left">
<div class="high"></div>
<div class="mid"></div>
<div class="low"></div>
</div>
<div class="right">
<div class="light">
<div class="up"></div>
<div class="down"></div>
</div>
<div class="dark">
<div class="up"></div>
<div class="down"></div>
</div>
</div>
</section>
<section class="cube">
<div class="top">
<div class="high"></div>
<div class="low"></div>
</div>
<div class="left">
<div class="high"></div>
<div class="mid"></div>
<div class="low"></div>
</div>
<div class="right">
<div class="light">
<div class="up"></div>
<div class="down"></div>
</div>
<div class="dark">
<div class="up"></div>
<div class="down"></div>
</div>
</div>
</section>
<section class="cube">
<div class="top">
<div class="high"></div>
<div class="low"></div>
</div>
<div class="left">
<div class="high"></div>
<div class="mid"></div>
<div class="low"></div>
</div>
<div class="right">
<div class="light">
<div class="up"></div>
<div class="down"></div>
</div>
<div class="dark">
<div class="up"></div>
<div class="down"></div>
</div>
</div>
</section>
</section>
JSFiddle:
http://jsfiddle.net/dGLMk/

Eliminate the Float
Using display: inline-block instead of float with a white-space: nowrap on the wrapping element along with some number tweaking gives you a solid line that does not move and allows for an overflow of the elements. Here is an example fiddle that may still need some slight adjustment on the top and left numbers, but gets close.

If you add a container div with overflow:hidden and the width you need, AND re-use the section even with width enought for the 3 cubes it should work.
Check here
.even {
width:700px;
}
.container {
overflow:hidden;
width:500px;
}
(and div .container is around the code you posted)
maybe a min-width could be also an option.

Apply this CSS to the rightmost cube that keeps wrapping down:
margin-right: -200px;
Here's a JSFiddle demo: http://jsfiddle.net/brentonstrine/dGLMk/2/. Note, this only solves it if it's the very rightmost one that's overflowing. If you need a solution to an arbitrary number of cubes overflowing, you'll need to set the .cube sections inside a container with overflow: hidden;, as Sergio suggests.

Related

Div is not shown in order

in my HTML code, I have some rows and div, but one div is shown before another, even if in the code is after. Div with class "contact" is shown before div with class "photos"
Photo: https://imgur.com/a/Y8BGQIM
<div class="photos">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8 section-heading">Galerie Foto</div>
</div>
<div class="gallery">
<img src="background1.jpeg" alt="Cinque Terre">
</div>
<div class="gallery">
<img src="galerie1.jfif" alt="Forest">
</div>
<div class="gallery">
<img src="galerie2.jfif" alt="Northern Lights">
</div>
<div class="gallery">
<img src="galerie3.jfif" alt="Mountains">
</div>
</div>
<div class="contact">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8 section-heading">Contact</div>
</div>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-6 section-subheading">
<h1><br>
<br>
</h1>
</div>
</div>
</div>
And the css code that I applied to the divs:
.photos{
width: 100%;
position: absolute;
background-color: black;
}
div.gallery {
border: 1px solid #ccc;
float: left;
}
.section-subheading:hover {
border: 5px solid #d3ae87;
}
div.gallery img {
width: 400px;
height: 400px;}
.contact{
width: 100%;
position: absolute;
background-color: black;
}
Hope deleting or commenting position: absolute in both the places will give you expected result.
Give a try. to below CSS
.photos{
width: 100%;
background-color: black;
}
div.gallery {
border: 1px solid #ccc;
float: left;
}
.section-subheading:hover {
border: 5px solid #d3ae87;
}
div.gallery img {
width: 400px;
height: 400px;}
.contact{
width: 100%;
background-color: black;
}
Position absolute will position both divs on top of one another at the top of the page if no other styling positions then differently. Remove the position absolute it is not needed here and add a float left to your photos class and your contact class so that the divs fall in order under one another because your gallery has a float left set.
.photos{
width: 100%;
float:left;
background-color: green;
}
div.gallery {
border: 1px solid #ccc;
float: left;
}
.section-subheading:hover {
border: 5px solid #d3ae87;
}
div.gallery img {
width: 400px;
height: 400px;}
.contact{
width: 100%;
background-color: black;
float:left;
}

CSS - <div> height

EDITED:
I have the following HTML code:
<div class="div-table">
<div class="div-table-row">
<div class="div-table-first-col">
<div>11:00</div>
</div>
<div class="div-table-col">
<div style="height: 11"></div>
<div class="appuntamentoContainer">
<div class="appuntamento" style="height: 25px">11:12 - 12:35</div> //--> need to stretch to bottom
</div>
</div>
<div class="div-table-col">
<div style="height: 0"></div>
<div class="appuntamento">11:00 - 11:45</div>
<div class="appuntamento">11:00 - 12:00</div>
<div class="appuntamento">11:45 - 12:30</div>
</div>
<div class="div-table-col">
<div style="height: "></div>
</div>
<div class="div-table-col">
<div style="height: "></div>
</div>
</div>
</div>
and CSS:
.div-table div.appuntamento {
background-color: #f3f2de;
padding: 3px 5px;
border: 1px solid #d7dde6;
border-radius: 5px;
}
.div-table {
display:table;
width:auto;
}
.div-table-row{
display:table-row;
width:auto;
clear:both;
height: 45px;
}
.div-table-col {
float:left;/*fix for buggy browsers*/
display:table-column;
width:154px;
}
.div-table-row .div-table-col{
border-left: 1px solid #d7dde6;
border-right: 1px solid #d7dde6;
border-top: 1px solid #d7dde6;
min-height: 44px;
}
.div-table-first-col {
float:left;/*fix for buggy browsers*/
display:table-column;
text-align: right;
width: 45px;
}
.div-table-first-col div{
padding: 3px 5px;
}
Here the fiddler
Notice the vertical borders. On the left side how it actually is, on the right side how it should. How do i stretch the div to the bottom?
Use the flexbox layout model. Just add display: flex; to .div-table-row, and remove any float or display property.
Here's the JSFiddle.
add height: 100% on parents table and td.
table {
height: 100%;
}
td {
height: 100%;
}
for reference look here: Make div stretch to fit td height
Check this out for some dynamic behaviour:
jQuery
var a=$(".second").outerHeight();
$(".first").height(a);
$(".third").height(a);
https://jsfiddle.net/1cejh0dL/6/

CSS3 Layout - 4 column with Polygin

I have a big problem with 4 columns layout inside my view.
I must build this layout:
Anybody know how I can make this layout? I use -clip method but first div always is another from last div. Two centered div is OK but first and last not.
Please, help me if you know how I can do this...
Here is an example using trapezoid borders in combination with positioning:
body {
margin: 0;
}
.section {
position: relative;
display: inline-block;
width: 25%;
margin-right: -4px;
}
.background {
position: absolute;
top: 0;
width: 100%;
height: 0;
border-right: 30px solid transparent;
border-bottom: 300px solid #346;
}
.content {
position: absolute;
top: 0;
color: #fff;
padding: 10px 10px 10px 30px;
z-index: 100;
}
.s1 .background {
border-bottom-color: yellow;
z-index: 5;
}
.s2 .background {
border-bottom-color: blue;
z-index: 4;
}
.s3 .background {
border-bottom-color: navy;
z-index: 3;
}
.s4 .background {
background-color: black;
border: none;
height: 300px;
}
<div class="section s1">
<div class="background"></div>
<div class="content">Lorem Ipsum</div>
</div>
<div class="section s2">
<div class="background"></div>
<div class="content">Lorem Ipsum</div>
</div>
<div class="section s3">
<div class="background"></div>
<div class="content">Lorem Ipsum</div>
</div>
<div class="section s4 last">
<div class="background"></div>
<div class="content">Lorem Ipsum</div>
</div>
Limits: You have to define a fixed height (300px in the example above)

How to make full 100% height of floated element?

I have the following html markup:
.container {
border: 1px solid green;
}
.right {
border: 1px solid #000;
float: right;
width: 40px;
}
.left {
border: 1px solid red;
overflow: hidden;
}
<div class="container">
<div class="right">Right</div>
<div class="left-container">
<div class="left">
Left fluid
<br/>
multiple rows
</div>
</div>
</div>
As you can see right block looks ugly. How could I make right element fluid height 100%?
Add the rule height:100% the right div, and remove float:right. I changed it to position:absolute, so that you didn't need the container's height.
.container {
border: 1px solid green;
position: relative;
width: 100%;
}
.right {
border: 1px solid #000;
width: 40px;
height: 100%;
position: absolute;
right: 0;
}
.left {
display: block;
border: 1px solid red;
overflow: hidden;
margin-right:40px;
}
<br><br><div class="container">
<div class="right">Right</div>
<div class="left-container">
<div class="left">
Left fluid
multiple rows a really long sentence a really long sentence a really long sentence a really long sentence a really long sentence a really long sentence.
</div>
</div>
</div>
If your application will run in a modern browser, then using flexbox is a good way to go: http://jsfiddle.net/2hn9zgog/.
HTML:
<div class="container">
<div class="right">Right</div>
<div class="left">
Left fluid
<br/>multiple rows
</div>
</div>
CSS:
.container {
display: flex;
width: 100%;
outline: 1px dotted gray;
}
.right {
order: 2;
flex: 0 0 auto;
border: 1px solid green;
}
.left {
flex: 1 0 auto;
border: 1px solid red;
}
add clear: both; after floated element.
<div class="right"></div>
<div style="clear: both"></div>
Add
html, body{
height: 100%;
min-height: 100%;
}
.your-container{
height: 100%;
}

CSS : Clamp divs to top and bottom in an inline container

[SOLVED]
Here's the Fiddle
<div id="container">
<div class="content">
<div class="column">
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
<div class="column">
<div class="top">
TOP
</div>
<div class="bottom">
BOTTOM
</div>
</div>
<div class="column">
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
</div>
</div>
#container .content .column {
position: relative;
display:inline-block;
height: 100%;
width: 100px;
border: 1px solid red;
}
#container .content .top,
#container .content .bottom {
position: absolute;
background-color: #AAA;
}
#container .content .top {
top: 0;
}
#container .content .bottom {
bottom: 0;
}
#container {
min-height: 349px;
}
I have three inline columns, the left and right ones have the same dynamic height (they contain generated tables with a variable number of rows)
I want the middle column to have the same height as its neighbours and I want his TOP div to clamp to the top and BOTTOM div to clamp to the bottom.
I've read this thread but can't manage to make it work.
Any idea what I'm doing wrong ?
Thanks a lot !
EDIT
Using Sowmya's solution :
JS Fiddle
<div id="container">
<div style="position: relative;">
<div class="content">
<div class="column">
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
<div class="column">
<div class="top">
TOP
</div>
<div class="bottom">
BOTTOM
</div>
</div>
<div class="column">
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
</div>
</div>
</div>
#container .content .column {
display:table-cell;
height: 100%;
width: 100px;
border: 1px solid red;
vertical-align: top;
}
#container .content .top,
#container .content .bottom {
position: absolute;
background-color: #AAA;
}
#container .content .top {
top: 0;
}
#container .content .bottom {
bottom: 0;
}
Use display:table-cell; to .column
#container .content .column {
position: relative;
display:table-cell;
height: 100%;
width: 100px;
border: 1px solid red;
}
DEMO