HTML Image on top of triangle background - html

I have an image on a triangle background, however there is seen a line crossing the image. I tried using z-index together with position both relative and absolute, but it doesn't seem to work. Can someone help me out? Much appreciated.
/* Reset. */
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
}
/* Panels. */
.splitview {
position: relative;
width: 100%;
min-height: 45vw;
overflow: hidden;
}
.panel {
position: absolute;
width: 100vw;
min-height: 45vw;
overflow: hidden;
}
.panel .content {
position: absolute;
width: 100vw;
min-height: 45vw;
color: #FFF;
}
.panel .description {
width: 25%;
position: absolute;
top: 50%;
transform: translateY(-50%);
text-align: center;
}
.panel img {
box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.15);
width: 35%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.bottom {
background-color: rgb(44, 44, 44);
z-index: 1;
}
.bottom .description {
right: 5%;
}
.top {
background-color: rgb(77, 69, 173);
z-index: 2;
width: 50vw;
/*-webkit-clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);
clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);*/
}
.top .description {
left: 5%;
}
/* Handle. */
.handle {
height: 100%;
position: absolute;
display: block;
width: 5px;
top: 0;
left: 50%;
z-index: 3;
}
/* Skewed. */
.skewed .handle {
top: 50%;
transform: rotate(30deg) translateY(-50%);
height: 200%;
-webkit-transform-origin: top;
-moz-transform-origin: top;
transform-origin: top;
}
.skewed .top {
transform: skew(-30deg);
margin-left: -1000px;
width: calc(50vw + 1000px);
}
.skewed .top .content {
transform: skew(30deg);
margin-left: 1000px;
}
/* Responsive. */
#media (max-width: 900px) {
body {
font-size: 75%;
}
}
<div class="splitview skewed">
<div class="panel bottom">
<div class="content">
<div class="description">
<h1>My name is John Snow.</h1>
<p>I like making popcorn with icicles alot.</p>
</div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Original">
</div>
</div>
<div class="panel top">
<div class="content">
<div class="description">
<h1>I dream about this girl everyday, but cannot seem to forget her.</h1>
<p>People say not many people can fall in love, and it's good I can experience it, but what is unrequited love worth actually.</p>
</div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Duotone">
</div>
</div>
<div class="handle"></div>
</div>

Use only one image and put it outside the panels.
/* Reset. */
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
}
.splitview img {
z-index: 3;
box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.15);
width: 35%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* Panels. */
.splitview {
position: relative;
width: 100%;
min-height: 45vw;
overflow: hidden;
}
.panel {
position: absolute;
width: 100vw;
min-height: 45vw;
overflow: hidden;
}
.panel .content {
position: absolute;
width: 100vw;
min-height: 45vw;
color: #FFF;
}
.panel .description {
width: 25%;
position: absolute;
top: 50%;
transform: translateY(-50%);
text-align: center;
}
.bottom {
background-color: rgb(44, 44, 44);
z-index: 1;
}
.bottom .description {
right: 5%;
}
.top {
background-color: rgb(77, 69, 173);
z-index: 2;
width: 50vw;
/*-webkit-clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);
clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);*/
}
.top .description {
left: 5%;
}
/* Handle. */
.handle {
height: 100%;
position: absolute;
display: block;
width: 5px;
top: 0;
left: 50%;
z-index: 3;
}
/* Skewed. */
.skewed .handle {
top: 50%;
transform: rotate(30deg) translateY(-50%);
height: 200%;
-webkit-transform-origin: top;
-moz-transform-origin: top;
transform-origin: top;
}
.skewed .top {
transform: skew(-30deg);
margin-left: -1000px;
width: calc(50vw + 1000px);
}
.skewed .top .content {
transform: skew(30deg);
margin-left: 1000px;
}
/* Responsive. */
#media (max-width: 900px) {
body {
font-size: 75%;
}
}
<div class="splitview skewed">
<div class="panel bottom">
<div class="content">
<div class="description">
<h1>My name is John Snow.</h1>
<p>I like making popcorn with icicles alot.</p>
</div>
</div>
</div>
<div class="panel top">
<div class="content">
<div class="description">
<h1>I dream about this girl everyday, but cannot seem to forget her.</h1>
<p>People say not many people can fall in love, and it's good I can experience it, but what is unrequited love worth actually.</p>
</div>
</div>
</div>
<div class="handle"></div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Duotone">
</div>

It can be hard to get two elements exactly lined up when there is some sort of transform or resizing going on because the arithmetic can result in part CSS pixel being required, and that can cause trouble translating to the multiple screen pixels that can make up a CSS pixel on modern, high res screens.
Your spurious line looks like not as wide as a CSS pixel and could be screen pixels 'left behind' during these calculations.
I found your layout quite hard to follow as there were skews and other transforms.
Looking at the layout I wonder if a simpler approach - a 3 column grid with flex used to center items within the panels might suffice? It would make maintenance easier. The skews seemed to be needed for the background 'triangular' shapes and this snippet replaces them with a sloping linear gradient as the content element's background. No skewing or other transforms are required.
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
}
.content {
position: absolute;
min-height: 45vw;
width: 100vw;
color: #fff;
text-align: center;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
background-image: linear-gradient(-60deg, rgb(44, 44, 44) 0, rgb(44, 44, 44) 48%, rgb(77, 69, 173) 48%, rgb(77, 69, 173) 100%);
}
.panel {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.panel .description {
width: 75%;
}
.panel img {
width: 100%;
height: 100%;
object-fit: contain;
/* commented out as I don't understand it's use here box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.15);*/
}
<body>
<div class="content">
<div class="panel">
<div class="description">
<h1>I dream about this girl everyday, but cannot seem to forget her.</h1>
<p>People say not many people can fall in love, and it's good I can experience it, but what is unrequited love worth actually.</p>
</div>
</div>
<div class="panel">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Original">
</div>
<div class="panel">
<div class="description">
<h1>My name is John Snow.</h1>
<p>I like making popcorn with icicles alot.</p>
</div>
</div>
</div>
<div class="handle"></div>
</div>
</body>

Related

Why margin is not respected in this case?

I can't figure out why a margin is not respected when I resize to mobile view. If you resize the window, left margin is respected, however, right margin is not respected.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.banner-container {
position: relative;
}
.banner-image {
height: 200px;
width: 100%;
background-color: rebeccapurple;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.banner-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 560px;
width: 100%;
background-color: rgba(255, 255, 255, 0.5);
text-align: center;
font-size: 32px;
padding: 24px 0;
margin: 0 10px;
}
#media screen and (max-width: 768px) {
.banner-text {
font-size: 24px;
}
}
<div class="banner-container">
<div class="banner-image"></div>
<span class="banner-text">Candidate Membership</span>
</div>
I'd appreciate if someone could explain what I'm doing wrong. Thanks.
The margin is there, but it is added to the 100% width you defined. So the element's width including margins goes beyond the container width.
.banner-text in media width : 80%
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.banner-container {
position: relative;
}
.banner-image {
height: 200px;
width: 100%;
background-color: rebeccapurple;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.banner-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 560px;
width: 100%;
background-color: rgba(255, 255, 255, 0.5);
text-align: center;
font-size: 32px;
padding: 24px 0;
margin: 0 10px;
}
#media screen and (max-width: 768px) {
.banner-text {
font-size: 24px;
}
.banner-text{
width: 80%;
}
}
<div class="banner-container">
<div class="banner-image"></div>
<span class="banner-text">Candidate Membership</span>
</div>

Centering of two hexagons

I have two hexagons, one is for the main background and other is for border, but the main inside hex is a little bit out of his place.
.hexagon {
position: relative;
width: 179.1px;
height: 103.40px;
margin: 51.70px 0;
border-left: solid 5px #c94400;
border-right: solid 5px #c94400;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
z-index: 1;
width: 126.64px;
height: 126.64px;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background-color: inherit;
left: 21.2286px;
}
.hexagon:before {
top: -63.3214px;
border-top: solid 7.0711px #c94400;
border-right: solid 7.0711px #c94400;
}
.hexagon:after {
bottom: -63.3214px;
border-bottom: solid 7.0711px #c94400;
border-left: solid 7.0711px #c94400;
}
.hexagon-inner {
position: relative;
width: 160px;
height: 92.38px;
background-color: rgba(42, 42, 42, 0.66);
margin: 46.19px 0;
}
.hexagon-inner:before,
.hexagon-inner:after {
content: "";
position: absolute;
width: 0;
border-left: 80px solid transparent;
border-right: 80px solid transparent;
}
.hexagon-inner:before {
bottom: 100%;
border-bottom: 46.19px solid rgba(42, 42, 42, 0.66);
}
.hexagon-inner:after {
top: 100%;
width: 0;
border-top: 46.19px solid rgba(42, 42, 42, 0.66);
}
}
<div class="hexagon">
<div class="hexagon-inner"></div>
</div>
How can i put in the middle my main hex to inside borders hex?
i tried to use margins from hexagon div, but both hex moving in the same time. What is the best way to center this hexagons?
How i expect : https://imgur.com/a/aUNHu8L
You can use "Flexbox" for horizontal and vertical center.You can learn in FlexBox Guide.For your solution, Remove margin from hexagon-inner class and add
display: flex;
align-items: center;
justify-content: center;
in hexagon class.
3 hexagons using clip-path - img on img
I offer another solution,
This is nice trick to achieve this, you can use percent or px.
.container {
height: 240px;
width: 240px;
background-image: url(https://wickes.scene7.com/is/image/travisperkins/GPID_1100100003_02?wid=824&hei=618&fit=crop);
background-size: cover;
display: flex;
align-items: center;
justify-content: center;
}
.hexagon {
transform: rotate(30deg);
/* height: 173.2px; */
/* width: 200px; */
height: 69.28%;
width: 80%;
position: relative;
}
.hex {
position: absolute;
clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.hexagon1 {
height: 100%;
width: 100%;
background-color: rgb(201, 68, 0);
}
.hexagon2 {
height: 92%;
width: 92%;
top: 4%;
left: 4%;
}
.copy-background {
transform: rotate(-30deg);
height: 124%;
width: 124%;
position: relative;
top: -12%;
left: -12%;
background-image: url(https://wickes.scene7.com/is/image/travisperkins/GPID_1100100003_02?wid=824&hei=618&fit=crop);
/* background-size: 320px; */
/* background-position: -6px -21px; */
background-size: 146%;
background-position: 10% 50%;
background-repeat: no-repeat;
}
.hexagon3 {
height: 84%;
width: 84%;
top: 8%;
left: 8%;
background-color: rgba(35, 35, 35, 0.7);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
}
.text {
transform: rotate(-30deg);
}
<div class="container">
<div class="hexagon">
<div class="hex hexagon1"></div>
<div class="hex hexagon2">
<div class="copy-background"></div>
</div>
<div class="hex hexagon3">
<span class="text">VONIA</span>
</div>
</div>
</div>
Another solution with not use px or percent, and you can change the position and the attachment - both - in .copy-background and .container
.container {
height: 240px;
width: 240px;
background-image: url(https://wickes.scene7.com/is/image/travisperkins/GPID_1100100003_02?wid=824&hei=618&fit=crop);
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
display: flex;
align-items: center;
justify-content: center;
}
.hexagon {
transform: rotate(30deg);
height: 69.28%;
width: 80%;
position: relative;
}
.hex {
position: absolute;
clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.hexagon1 {
height: 100%;
width: 100%;
background-color: rgb(201, 68, 0);
}
.hexagon2 {
height: 92%;
width: 92%;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.copy-background {
overflow: hidden;
top: 0;
left: -18%;
right: 0;
bottom: 0;
margin: auto;
height: 240px;
width: 240px;
transform: rotate(-30deg);
position: absolute;
background-image: url(https://wickes.scene7.com/is/image/travisperkins/GPID_1100100003_02?wid=824&hei=618&fit=crop);
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
}
.hexagon3 {
height: 84%;
width: 84%;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background-color: rgba(35, 35, 35, 0.7);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
}
.text {
transform: rotate(-30deg);
}
<div class="container">
<div class="hexagon">
<div class="hex hexagon1"></div>
<div class="hex hexagon2">
<div class="copy-background"></div>
</div>
<div class="hex hexagon3">
<span class="text">VONIA</span>
</div>
</div>
</div>

Stretch divider to one side but keep title centered

Please run the example below. I'm trying to stretch the left line further to the left to compensate the parent's padding as you can see in the second example, while keeping the title centered relative to the parent like in the first example. I can't seem to have both.
(For anyone who's familiar, the divider I'm trying to tweak comes from ant-design)
#container {
height: 100px;
width: 400px;
background: #EFEFEF;
padding: 24px;
}
/* Normal use case */
.divider {
position: relative;
line-height: 23px;
height: 1px;
display: table;
margin: 16px 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 15px;
white-space: nowrap;
text-align: center;
background: transparent;
}
.divider::before, .divider::after {
position: relative;
top: 50%;
display: table-cell;
width: 50%;
border-top: 1px solid #AAA;
-webkit-transform: translateY(50%);
-ms-transform: translateY(50%);
transform: translateY(50%);
content: '';
}
.divider-text {
display: inline-block;
padding: 0 24px;
}
/* Trying to stretch the left line to further to the left without puting the title off-center */
.divider.stretched-left {
left: -24px;
width: calc(100% + 24px);
min-width: calc(100% + 24px);
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-left">
<span class="divider-text">Title</span>
</div>
</div>
First, I would use flexbox instead of table layout then adjust the margin/padding:
Kept only the relevant code for the demo
#container {
width: 400px;
background: #EFEFEF;
padding: 24px;
}
/* Normal use case */
.divider {
display: flex;
margin: 16px 0;
align-items:center;
}
.divider::before, .divider::after {
flex:1;
height: 1px;
background:#AAA;
content: '';
}
.divider::before {
margin-right:24px;
}
.divider::after {
margin-left:24px;
}
.divider.stretched-left:before {
margin-left:-24px;
padding-left: 24px;
}
.divider.stretched-right:after {
margin-right:-24px;
padding-right: 24px;
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-left">
<span class="divider-text">another Title</span>
</div>
<div class="divider stretched-right">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-right">
<span class="divider-text">another Title</span>
</div>
<div class="divider stretched-left stretched-right">
<span class="divider-text">another Title</span>
</div>
</div>
With your original code you can try this:
#container {
height: 100px;
width: 400px;
background: #EFEFEF;
padding: 24px;
}
/* Normal use case */
.divider {
position: relative;
line-height: 23px;
height: 1px;
display: table;
margin: 16px 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 15px;
white-space: nowrap;
text-align: center;
background: transparent;
}
.divider::before, .divider::after {
position: relative;
top: 50%;
display: table-cell;
width: 50%;
border-top: 1px solid #AAA;
transform: translateY(50%);
content: '';
}
.divider-text {
display: inline-block;
padding: 0 24px;
}
/* Trying to stretch the left line to further to the left without puting the title off-center */
.divider.stretched-left {
left: -24px;
width: calc(100% + 48px); /* Updated */
}
/* Added */
.divider.stretched-left:after {
border-image:linear-gradient(to left,transparent 24px, #aaa 24px) 1;
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-left">
<span class="divider-text">Title</span>
</div>
</div>
#container {
height: 100px;
width: 400px;
background: #EFEFEF;
padding: 24px;
}
.divider {
position: relative;
line-height: 23px;
height: 1px;
display: table;
margin: 16px 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 15px;
white-space: nowrap;
text-align: center;
background: transparent;
width: 100%; /* SOLUTION – this is new */
}
.divider::before, .divider::after {
position: absolute; /* SOLUTION – this has changed */
top: 50%;
display: table-cell;
width: 41%; /* SOLUTION – changed, matches desired layout best */
border-top: 1px solid #AAA;
-webkit-transform: translateY(50%);
-ms-transform: translateY(50%);
transform: translateY(50%);
content: '';
}
.divider::before{
left: -24px; /* SOLUTION – compensate #container padding */
width: calc( 41% + 24px ); /* SOLUTION – add the offset to the width */
}
.divider::after{
right: 0px; /* SOLUTION */
}
.divider-text {
display: inline-block;
padding: 0 24px;
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
</div>
.divider.stretched-left {
left: -24px;
width: calc(100% + 48px);
min-width: calc(100% + 48px);
}
Just You have to replace last css lines code with above given code.
Solution with minimum CSS, without flex, without transform.
.divider {
position: relative;
text-align:center;
}
.divider:before {
content:'';
position: absolute;
top:50%;
height: 1px;
width: 100%;
background: #000;
left: 0;
z-index: -1;
}
.divider span{
padding: 0 24px;
z-index: 1;
background: #fff;
display: inline-block;
}
<div class="divider">
<span>Title</span>
</div>

Responsive CSS Horizontal Scroll

I am trying to add a horizontal scroll onto a page so that when you scroll vertically, the page scrolls horizontally. I found a piece of code that can do this which is entirely CSS based however it doesn't seem to be responsive. I found this on CodePen.
Is there any way in which this code can be transformed into the page being responsive?
I've attached the code below.
#container {
margin-top: -15px;
}
#container .box {
width: 100vw;
height: 100vh;
display: inline-block;
position: relative;
}
#container .box>div {
width: 100%;
height: 100%;
font-size: 96px;
color: #FFF;
position: absolute;
top: 5%;
left: 2.6%;
margin: -50px 0 0 -50px;
line-height: .7;
font-weight: bold;
}
#container {
overflow-y: scroll;
overflow-x: hidden;
transform: rotate(270deg) translateX(-100%);
transform-origin: top left;
background-color: #999;
position: absolute;
width: 100vh;
height: 100vw;
}
#container2 {
transform: rotate(90deg) translateY(-100vh);
transform-origin: top left;
white-space: nowrap;
font-size: 0;
}
.one {
background-color: #45CCFF;
}
.two {
background-color: #49E83E;
}
.three {
background-color: #EDDE05;
}
.four {
background-color: #E84B30;
}
<div id="container">
<div id="container2">
<div class="box one">
<div class="full">
<img class="desktop" src="public/images/lookbook/4.jpg" alt="Header" />
</div>
</div>
<div class="box two">
<div>2</div>
</div>
<div class="box three">
<div>3</div>
</div>
<div class="box four">
<div>Last</div>
</div>
</div>
</div>
If anyone has any idea - please let me know!
I took the initiative to remove all those ugly white spaces and scroll bars, plus what you asked for: Codepen
body,
html {
height: 100%;
width: 100%;
margin: 0;
}
#container {
width: calc(100vh + 17px);
height: 100vw;
margin-top: -17px;
margin-right: 100px;
overflow-y: scroll;
overflow-x: hidden;
transform: rotate(270deg) translateX(-100%);
transform-origin: top left;
background-color: #999;
position: absolute;
}
#container2 {
transform: rotate(90deg) translateY(-100vh);
transform-origin: top left;
white-space: nowrap;
font-size: 0;
}
#container .box {
width: 100vw;
height: 100vh;
display: inline-block;
position: relative;
}
#container .box > div {
font-size: 96px;
color: #FFF;
position: absolute;
top: 0;
left: 0;
margin: 0;
line-height: 0.9;
font-weight: bold;
}
.full {
height: 100%;
width: 100%;
position: relative;
}
.desktop {
width: 100%;
height: 100%;
display: block;
position: absolute;
background-size: cover;
}
.one {background-color: #45CCFF;}
.two {background-color: #49E83E;}
.three {background-color: #EDDE05;}
.four {background-color: #E84B30;}
Here is the code you want, use the image as a background instead. This allows it to cover the div completely as you'd like it to. Whilst also being responsive.
body,
html {
height: 100%;
width: 100%;
margin: 0;
}
#container .box {
width: 100vw;
height: 100vh;
display: inline-block;
position: relative;
background-size: cover;
}
#container .box>div {
width: 100%;
height: 100%;
font-size: 96px;
color: #FFF;
position: absolute;
top: 5%;
margin: 20px 0px 0px;
line-height: .7;
font-weight: bold;
}
#container {
overflow-y: scroll;
overflow-x: hidden;
transform: rotate(270deg) translateX(-100%);
transform-origin: top left;
background-color: #999;
position: absolute;
width: 100vh;
height: 100vw;
}
#container2 {
transform: rotate(90deg) translateY(-100vh);
transform-origin: top left;
white-space: nowrap;
font-size: 0;
}
.one {
background-color: #45CCFF;
background-image: url(https://images.pexels.com/photos/1022454/pexels-photo-1022454.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260);
}
.two {
background-color: #49E83E;
background-image: url(https://images.pexels.com/photos/1023949/pexels-photo-1023949.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260);
}
.three {
background-color: #EDDE05;
background-image: url(https://images.pexels.com/photos/963071/pexels-photo-963071.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260);
}
.four {
background-color: #E84B30;
background-image: url(https://images.pexels.com/photos/1022928/pexels-photo-1022928.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260);
}
<div id="container">
<div id="container2">
<div class="box one">
<div class="full">
<div>1</div>
</div>
</div>
<div class="box two">
<div>2</div>
</div>
<div class="box three">
<div>3</div>
</div>
<div class="box four">
<div>Last</div>
</div>
</div>
</div>

Create footer with two different colors

I am trying to create a footer according to a design I received ...
The background color on the left is different from the right one:
I have the following markup:
<div class"wrapper">
<div class="content">
The Text here should no go over the logo
</div>
</div>
My idea is Content DIV to have the logo as background image aligned left and no repeat.
But then I don't know how to create the different color on left and right ...
And I am not sure if I can control the height so that everything aligns.
The content div is centered and has the orange border on the image ...
Thank You,
Miguel
Try this http://codepen.io/nicknameless/pen/cblzB/
I've used CSS3 and no additional markup. This should work for you. It could be cleaned up I think, this is just a quick overview to get you started.
The HTML you provided
<div class="wrapper">
<div class="content">
The Text here should no go over the logo
</div>
</div>
The CSS
html, body {
padding: 0;
margin: 0;
}
div.wrapper {
height: 40px;
background: #850000;
width: 100%;
display: block;
position: relative;
overflow: visible;
top: calc( 100px - 40px );
}
div.wrapper:before {
background: transparent url('http://placehold.it/100x100') no-repeat 0 0;
content: " ";
width: 100px;
height: 100px;
position: absolute;
bottom: 0;
left: 10%;
}
div.content {
left: calc( 10% + 100px );
padding-left: 10px;
bottom: 0;
background-color: #C70000;
display: block;
height: 40px;
position: absolute;
width: calc( 100% - ( 10% + 100px ) );
}
It's was really a pain in the ass, I recommend to take the inner rectangle as a picture, but if you really want it in CSS, here it's: http://jsfiddle.net/B97ym/
HTML:
<div class='wrapper'>
<div class="content">The Text</div>
<div class='border'>
<div class='border2'></div>
<div class='border3'></div>
<div class='logodiv'>
<div class='rectangle'></div>
</div>
</div>
CSS:
.wrapper {
width: 500px;
height: 50px;
margin: 100px auto;
position: relative;
background: linear-gradient(to right, #9c9e9f 40%, #000000 40%);
}
.content{
margin: 0 0 0 50%;
color: #ffffff;
}
.border{
width: 4em;
height: 4em;
background: #FF0000;
position: absolute;
left: 33.7%;
top: -55%;
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
background: linear-gradient(to top, #000000 62%, #9c9e9f 62%);
}
.border2{
width: 0.8em;
height: 4em;
background: #9c9e9f;
position: absolute;
left: 80%;
}
.border3{
width: 0.8em;
height: 0.85em;
background: #000000;
position: absolute;
left: 80%;
top: 80%;
}
.logodiv {
width: 2.5em;
height: 2.5em;
background: #ffffff;
position: absolute;
top: 18%;
left: 18%;
}
.rectangle{
width: 2.1em;
height: 2.1em;
position: relative;
background: #ffffff;
top: -42%;
left: -42%;
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
}
Hope it's will be helpful to someone (:
Use a CSS background-image on the wrapper layer that contains the entire logo, bars an all. Add enough margin-left on the inner layer to shove the text beyond the logo.
Create a div with two div's inside with 50% width for left and right and fixed height. Make sure you overflow the logo.
I wonder if this FIDDLE will give you a place to start.
CSS
.holder {
width: 500px;
margin: 100px auto;
position: relative;
}
.leftdiv {
width: 40%;
height: 60px;
float: left;
background-color: red;
}
.rightdiv {
width: 60%;
height: 60px;
float: left;
background-color: blue;
}
.logodiv {
width: 44px;
height: 44px;
position: absolute;
left: 157px;
top: -42px;
background-color: white;
transform: rotate(45deg);
border-left: 20px solid blue;
border-right: 20px solid red;
border-top: 20px solid red;
border-bottom: 20px solid blue;
}
.whiteout {
background-color: white;
width: 30px;
height: 60px;
border: 0px solid black;
position: absolute;
top: -60px;
left: 183px;
}