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)
Related
I need help to create the following view. I can definitely use position absolute but is there a way to do it without using the absolute value?
.balls {
display: flex;
}
.balls>.left {
height: 2.3rem;
width: 2.4rem;
border-radius: 50%;
margin-right: -0.9rem;
border: 4px solid white;
background-color: red;
}
.center_ball {
z-index: 99999;
}
.left_ball2 {
z-index: 9999;
}
.right_ball2 {
z-index: 99;
}
<div class="balls">
<div class="left"></div>
<div class="left left_ball2"></div>
<div class="left center_ball"></div>
<div class="left right_ball2"></div>
<div class="left"></div>
</div>
I think something like this? Adding a display: flex to make them stay on the same row, and a negative margin to make them override each other.
.balls {
display: flex;
}
.balls > .left {
height: 2.3rem;
width: 2.4rem;
border-radius: 50%;
margin-right: -0.9rem;
border: 4px solid white;
background-color: red;
}
<div class="balls">
<div class="left"></div>
<div class="left"></div>
<div class="left"></div>
<div class="left"></div>
<div class="left"></div>
</div>
Here you have a snippet with live example
.first {
z-index: 1;
border: 2px solid blue;
position: relative;
}
.second {
z-index: 2;
left: -60px;
position: relative;
top: 10px;
border: 2px solid red;
}
.third {
z-index: 1;
left: -100px;
position: relative;
border: 2px solid green;
}
<div>
<img src="https://fr.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-fr.svg" class="first">
<img src="https://fr.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-fr.svg" class="second">
<img src="https://fr.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-fr.svg" class="third">
</div>
I want to make this:
stacked cards
the html would look like so:
<div class="container>
<div class="top-card>
<div class="card-content">
...
</div>
</div>
<div class="bottom-card>
</div>
</div>
I am having trouble styling this so that the height of the entire card adjusts automatically according to the content inside the top card. Thank you in advance.
you can use a combination of box-shadow and display: inline-block to accomplish what you are trying to do. I have updated the answer. Here is the code:
.grandparent {
display: inline-block;
position: relative;
}
.parent {
display: inline-block;
background: blue;
position: absolute;
top: 0;
left: 0;
}
.child {
width: 100px;
height: 100px;
background: red;
margin: 5px;
}
.shadow {
margin-left: -7px;
margin-top: -7px;
background: pink;
z-index: -100;
border: 1px solid green;
}
.empty {
opacity: 0;
}
<div class="grandparent">
<div class="parent">
<div class="child"></div>
</div>
<div class="parent shadow">
<div class="child empty"></div>
</div>
</div>
I have a nested Table in which I have to show a Tooltip for the texts. I have extracted the problem in an jsfiddle, the problem is that I can not position the blue Element on top of the Block 2.1 Content even if i set z-index very big.
Here again the html and css code to that:
.block {
display: block;
}
.content {
border: 1px solid #ccc;
padding: 2px 5px;
box-shadow: 5px 5px 10px black;
height: 30px;
width: 90%;
line-height: 30px
}
.block1_content {
z-index: 3;
position: relative;
background: white;
}
.block2_content {
z-index: 2;
margin-left: 10px;
position: relative;
background: #ccc;
}
.tooltip {
position: absolute;
display: block;
background: blue;
color: white;
height: 40px;
width: 100px;
z-index: 99999;
padding: 5px 10px;
top: 15px
}
<div class="block1 block">
<div class="block1_content content">Block 1 Content</div>
<div class="block2 block">
<div class="block2_content content">
Block2 Content
<div class="tooltip">Tooltip</div>
</div>
</div>
</div>
<div class="block1 block">
<div class="block1_content content">Block 2.1 Content</div>
<div class="block2 block">
<div class="block2_content content"> Block 2.2 Content</div>
</div>
</div>
EDIT
Here a little bit complicated version of the code/problem as requested.
hope this helps you. thanks
.block {
display: block;
}
.relative{
position: relative
}
.content {
border: 1px solid #ccc;
padding: 2px 5px;
box-shadow: 5px 5px 10px black;
height: 30px;
width: 90%;
line-height: 30px
}
.block1_content {
z-index: 3;
position: relative;
background: white;
}
.block2_content {
z-index: 2;
margin-left: 10px;
position: relative;
background: #ccc;
}
.tooltip {
position: absolute;
display: block;
background: blue;
color: white;
height: 40px;
width: 100px;
z-index: 99999;
padding: 5px 10px;
top: 15px
}
<div class="block1 block">
<div class="block1_content content">Block 1 Content</div>
<div class="block2 block">
<div class="block2_content content">
Block2 Content
</div>
</div>
</div>
<div class="block1 block relative">
<div class="tooltip">Tooltip</div>
<div class="block1_content content">Block 2.1 Content</div>
<div class="block2 block">
<div class="block2_content content"> Block 2.2 Content</div>
</div>
</div>
I am trying to make a layout where #txt-bar and #main-content-area will overlap on #image. ( #txt-bar is overlapping on #image with following CSS ) but to achieve overlapping of #main-content-area on #image if I use top:-60px at #main-content-area then it will leave a gap between #main-content-area and #footer. I don't know how to solve this issue. Please help me.
/* CSS */
body {
position: absolute;
}
#top-bar {
background-color: black;
color: white;
}
#txt-bar {
height: 40px;
background-color: pink;
position: relative;
z-index: 4;
}
#link-bar {
background-color: red;
height: 40px;
z-index: 4;
}
#image {
position: relative;
z-index: 3;
}
.line {
width: 100%;
position: relative;
border-bottom: 4px solid black;
}
#main-content-area {
position: relative;
background-color: red;
top: -60px;
z-index: 4;
}
#footer {
background-color: green;
position: relative;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-sm-6" id="txt-bar">
<h1>Greetings</h1>
</div>
<div class="col-sm-6" id="link-bar">
<h1>Link bar </h1>
</div>
</div>
<div class="row">
<div class="col-sm-12" id="image">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300" class="img-responsive" />
</div>
</div>
<div class="line"></div>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-8" id="main-content-area">
<h1>Main content area </h1>
</div>
<div class="col-sm-2">
</div>
</div>
<div class="row" id="footer">
<div class="col-sm-12">
<h1>Footer Element </h1>
</div>
</div>
</div>
Wrap all divs (#txt-bar #main-content-area and #image) in a parent div with position:relative then use position:absolute for #main-content-area and #txt-bar, this will solve your issues.
.wrap{position:relative;max-width:300px;}
#txt-bar {
height: 40px;
background-color: pink;
position: absolute;
top:10px;
width:100%;
}
#main-content-area {
position: absolute;
bottom:10px;
width:100%;
background-color: red;
}
<div class=wrap>
<div id=txt-bar>txt-bar</div>
<div id=image><img src=https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300></div>
<div id=main-content-area>main-content-area</div>
</div>
More Info
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.