Diagonally divs filling complete space of parent div - html

I'm trying to create a div with relative height and width, in which are three boxes, being diagonally aligned and also fill the complete space of the relative parent div.
It's kinda tough for me to explain, so here's a picture on how I mean it: http://i.imgur.com/s2uSTVU.png
Besides the little space between the red lines all the space should be covered by the diagonal boxes.
Is that possible somehow? I'm very grateful for every advice or tip someone can shoot me!
Following code is what I got so far. The problem now where I'm stuck is how to make the diagonal divs fill out the complete space around them.
<div class="parent">
<div class="box-1">box1</div>
<div class="box-2">box2</div>
<div class="box-3">box3</div>
</div>
CSS:
.box-1 {
-ms-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
width: 100%;
margin: 0px 0px 10px 0px;
height: 33.33%; }
.box-2 {
-ms-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
width: 100%;
margin: 0px 0px 10px 0px;
height: 33.33%; }
.box-3 {
-ms-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
width: 100%;
height: 33.33%; }
Greetings, Toumazi!

You could try that: fiddle
.parent {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
.parent > div {
background: #c1c1c1;
}
.box-1 {
-ms-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
width: 100%;
margin: 0px 0px 10px 0px;
height: 33.33%; }
.box-2 {
-ms-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
width: 100%;
margin: 0px 0px 10px 0px;
height: 33.33%; }
.box-3 {
-ms-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
width: 100%;
height: 33.33%; }

Related

HTML CSS Ken Burns distorted effect

I have a website with a header image ( 3279 x 710 px ) and I added a Ken Burns effect to it, but it seems like it is distorted. I made a fiddle with a test image, but i can't reproduce the distorted effect, however it has something to do with it's aspect ratio. The Image looks like it's pressed together.
Right now i tried to fix it with width set to auto and height to 100%, but I can't get it to work.
I made a fiddle here.
HTML
<div id="header-wrapper" class="wrapper">
<img src='http://eventzerz.com/wp-content/uploads/2018/03/Test-Logo-Small-Black-transparent-1.png' class='image-kenburns'>
<div id="header">
</div>
</div>
CSS
#header-wrapper {
background: transparent;
padding: 0;
}
.wrapper {
padding: 6em 0 9em 0;
}
.wrapper .title {
font-size: 0.9em;
width: 25em;
/*
height: 3.25em;
*/
height: 3.4em;
top: -3.25em;
line-height: 3.25em;
margin-bottom: -3.25em;
margin-left: -12.5em;
padding-top: 0.5em;
}
#header {
position: relative;
padding: 12em 0;
}
.homepage #header {
padding: 18em 0;
}
.image-kenburns {
overflow: hidden;
position: absolute;
z-index: -1;
animation: move 40s ease-in infinite;
height: 100%;
width: 100%;
}
#keyframes move {
0% {
-webkit-transform-origin: bottom left;
-moz-transform-origin: bottom left;
-ms-transform-origin: bottom left;
-o-transform-origin: bottom left;
transform-origin: bottom right;
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
50% {
transform: scale(1.2);
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
-o-transform: scale(1.2);
-moz-transform: scale(1.2);
}
100% {
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
}
EDIT: I should mention that it's fine looking on desktop, what I need is the responsive version for tablets.
If you need your image to resize proportionally / keep the aspect ratio just add to your .image-kenburns class height: auto

Image/Link is stuck to top-left, even when position is changed

This is my CSS and HTML.
div.musiclink {
position: relative;
}
a.music {
width: 258px;
height: 117px;
display: block;
background: deepskyblue url('MUSIC-cursive.png') center top no-repeat;
-webkit-transform: rotate(330deg);
-moz-transform: rotate(330deg);
-ms-transform: rotate(330deg);
-o-transform: rotate(330deg);
transform: rotate(330deg);
}
a.music:hover {
background-image: url('MUSIC-cursive-hover.png');
}
a.store {
position: relative;
left: 500px;
top: 100px;
width: 220px;
height: 110px;
display: block;
background: deeppink url('STORE-cursive.png') center top no-repeat;
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
transform: rotate(30deg);
}
a.store:hover {
background-image: url('STORE-cursive-hover.png');
}
<div class="musiclink">
</div>
<div class="storelink">
</div>
The thing is I positioned everything successfully when I used images instead of href links, but now nothing is working the way I want it to. I don't want the images/links to move when I resize the browser.

How make 3 divs skew in css

How to make a 3 div with distortion, as shown in the picture?
I have made this:
.cars {
width: 100%;
height: 500px;
}
.car {
width: 33.33333333%;
height: 100%;
background: #3498db;
position: relative;
-webkit-transform: skewx(-10deg);
-moz-transform: skewx(-10deg);
-o-transform: skewx(-10deg);
-ms-transform: skewx(-10deg);
transform: skewx(-10deg);
transform-origin: top left;
float: left;
display: inline;
}
.car:nth-child(2) {
background: #000
}
.car:nth-child(3) {
background: #ff0000
}
<div class="cars">
<div class="car"></div>
<div class="car"></div>
<div class="car"></div>
</div>
jsFiddle
Left div - left corner straight, right corner slanted
Center div - left and right corner slanted
Right div - left corner slanted, right corner straight
I have used CSS's :after pseudo class to add another red box after the last, slanted one. However this one isn't slanted, thus 'filling in' the bit of the slant that you don't want:
.car:nth-child(3):after {
/* create the box */
content: "";
display: block;
/* make it fill the required space */
width: 80%; /* (this is only 80 because it was a bit large at 100) */
height: 100%;
background: #ff0000;
/* transform it in the opposite direction to counter the -10deg skew of .car */
-webkit-transform: skewx(10deg);
-moz-transform: skewx(10deg);
-o-transform: skewx(10deg);
-ms-transform: skewx(10deg);
transform: skewx(10deg);
transform-origin: top left;
position: relative;
right: -20%; /* counteract the 80% width */
}
I did the same with the first div, and :before:
.car:nth-child(3):before{
content: "";
display: block;
width: 70%;
height: 100%;
background: #3498db;
-webkit-transform: skewx(10deg);
-moz-transform: skewx(10deg);
-o-transform: skewx(10deg);
-ms-transform: skewx(10deg);
transform: skewx(10deg);
transform-origin: top left;
position: relative;
right: 40%;
}
.cars {
width: 100%;
height: 500px;
margin-left: 100px;
}
.car {
width: 33.33333333%;
height: 100%;
background: #3498db;
position: relative;
-webkit-transform: skewx(-10deg);
-moz-transform: skewx(-10deg);
-o-transform: skewx(-10deg);
-ms-transform: skewx(-10deg);
transform: skewx(-10deg);
transform-origin: top left;
float: left;
display: inline;
}
.car:nth-child(2) {
background: #000;
}
.car:nth-child(3) {
background: #ff0000;
}
.car:nth-child(3):after {
content: "";
display: block;
width: 70%;
height: 100%;
background: #ff0000;
-webkit-transform: skewx(10deg);
-moz-transform: skewx(10deg);
-o-transform: skewx(10deg);
-ms-transform: skewx(10deg);
transform: skewx(10deg);
transform-origin: top left;
position: relative;
right: -30%;
}
.car:nth-child(1):before {
content: "";
display: block;
width: 70%;
height: 100%;
background: #3498db;
-webkit-transform: skewx(10deg);
-moz-transform: skewx(10deg);
-o-transform: skewx(10deg);
-ms-transform: skewx(10deg);
transform: skewx(10deg);
transform-origin: top left;
position: relative;
right: 40%;
}
<div class="cars">
<div class="car first"></div>
<div class="car"></div>
<div class="car last"></div>
</div>
<br><br>

Placing an image centrally over another image with responsive width and height

How to place an image centrally over another image?
I tried the answers from so many similar questions, but none of them work for me.
Basically I need the 2 images to become 1 and
it MUST be RESPONSIVE(so the size changes automatically when different screen size devices access the web page.)
The heart and ring should remain the same position to each other when user resize his or her screen(or web page window size etc.)
I am trying to use css to draw both the ring and the heart, but it is okay if you really need the picture to replace the ring or heart.
Here is my code, I have been working on it for hours but haven't got any good luck.
http://jsfiddle.net/4u6tfacw/
Thank you.
Here is my code
<div id="logo">
<div id="heart-container">
</div>
<div id="heart">
</div>
</div>
#logo {
width: 50%;
height: 50%;
}
#heart {
display: block;
position: absolute;
top: 70px;
left: 30px;
z-index: 1;
width: 70%;
height: 70%;
}
#heart-container {
display: block;
position: absolute;
top: 0;
left: 0;
/*bottom:0;
right:0;*/
z-index: 1;
width: 70%;
height: 70%;
}
#heart-container {
border-radius: 50%;
behavior: url(PIE.htc);
width: 220px;
height: 220px;
padding: 8px;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 90px;
top: 0;
width: 90px;
height: 130px;
background: red;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
box-shadow: 10px 10px 100px #6d0019;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
Well, here is my attempt to satisfy the requirements of the question — which is not only about putting an image/element over another one, but about achieving that in a responsive manner.
Key points
Using a percentage value on bottom padding to make elements' heights respect their width1.
Using percentage values on top, right, left, bottom offsets as well as width and height properties2.
Using a high value in pixels on border-radius instead of percentage — for instance 1000px.
And number four... well, the last step is trial and error!
Example on JSFiddle.
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
margin: 0;
height: 100%;
width: 100%;
}
#logo {
width: 50%;
/* height: 50%; */
position: relative;
}
#logo:after {
content: "";
display: block;
padding-bottom: 70%;
}
#heart {
position: absolute;
top: 26%;
left: 35%;
z-index: 1;
width: 70%;
height: 100%;
}
#heart-container {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 70%;
/* height: 70%; */
border-radius: 50%;
behavior: url(PIE.htc);
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
#heart-container:after {
content: "";
display: block;
padding-bottom: 100%;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 0;
top: 0;
width: 39.130434782608695652173913043478%;
height: 56.521739130434782608695652173913%;
background: red;
-moz-border-radius: 1000px 1000px 0 0;
border-radius: 1000px 1000px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: -38.9%;
box-shadow: 10px 10px 100px #6d0019;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
<div id="logo">
<div id="heart-container"></div>
<div id="heart"></div>
</div>
1 Have a look at Responsive Container section of this topic.
2 To find exact values, we can position/size things in an absolute length — like px — and then just measure things relative to each other.
If you want to go responsive, you'd have to drop all the fixed (pixel) units and use percentages unless you plan to have several versions depending on the screen size and in that case you can use media queries.
So, the idea is to use percentages for paddings, margins, etc... and I've replaced the fixed width/height definitions you had with percentual padding, which made the circle responsive. See if you can do the same for the heart (I think using an image might save you a lot of time here).
#logo {
width: 50%;
height: 50%;
position: relative;
}
#heart {
display: block;
position: absolute;
margin: 18% 14%;
z-index: 1;
width: 70%;
height: 70%;
}
#heart-container {
display: block;
position: absolute;
top: 0;
left: 0;
/*bottom:0;
right:0;*/
z-index: 1;
padding: 50%;
}
#heart-container {
border-radius: 50%;
behavior: url(PIE.htc);
padding: 50%;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 90px;
top: 0;
width: 90px;
height: 130px;
background: red;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
box-shadow: 10px 10px 100px #6d0019;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
<div id="logo">
<div id="heart-container">
</div>
<div id="heart">
</div>
</div>
And the fiddle: http://jsfiddle.net/fzgd6cv8/
Let me know if you have trouble doing the same thing for the heart.
UPDATE
Here's my attempt for the heart, probably needs a bit of number tweaking:
#logo {
width: 50%;
height: 50%;
position: relative;
}
#heart {
display: block;
position: absolute;
margin: 20% 14% 0 9%;
z-index: 1;
width: 70%;
height: 70%;
}
#heart-container {
display: block;
position: absolute;
top: 0;
left: 0;
/*bottom:0;
right:0;*/
z-index: 1;
padding: 50%;
}
#heart-container {
border-radius: 50%;
behavior: url(PIE.htc);
padding: 50%;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 60%;
top: 0;
width: 60%;
padding-top: 100%;
background: red;
-moz-border-radius: 150% 150% 0 0;
border-radius: 150% 150% 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
box-shadow: 10px 10px 100px #6d0019;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
<div id="logo">
<div id="heart-container">
</div>
<div id="heart"></div>
</div>
http://jsfiddle.net/fzgd6cv8/2/

CSS - Deactivate top div

How can I deactivate the top DIV so that I can select what's under it?
Check what I did here:
http://jsfiddle.net/zE5Ze/2/
#triangle_w {
width: 1000px;
height: 178px;
overflow: hidden;
position: fixed;
left: -24px;
top: -82px;
/*outline: 1px solid pink;*/
-moz-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
}
#triangle {
width: 961px;
height: 176px;
background: url('http://i.imgur.com/FTGa2.png') no-repeat;
position: absolute;
left: 10px;
bottom: -80px;
/*outline: 1px solid red;*/
-moz-transform: rotate(10deg);
-webkit-transform: rotate(10deg);
}
#triangle #menu {
-moz-transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
/*outline: 1px solid red;*/
}
Without the rotation: http://jsfiddle.net/zE5Ze/5/
As you can see, the areas inside the red outline are not selectable.
Is there a way to do this without having to fiddle with CSS rotations?
I'd like to deactivate the triangle, and leave only the menu and the thumbs active.
Simple. Give a z-index.
#triangle #menu a {z-index: 5;}
Fiddle: http://jsfiddle.net/zE5Ze/3/
Or set a width!
#triangle_w {width: 100px;}
Fiddle: http://jsfiddle.net/zE5Ze/4/