How to center elements during a hover action in CSS - html

So I'm learning CSS and I'm still getting used to being able to correctly position all the elements. Right now, I have an HTML and CSS file that draws what basically looks like the Android robot. There's an action for the head that if you hover over it, it changes its width to 300px. The problem is that the eyes become uncentered. How can I center the eyes during the hover event?
EDIT: Bonus question; in the .eyes portion of the CSS file, I was wondering why just doing display: flex centers the eyes. I thought I would have to add align_items: center to center it across the cross axis, but just doing that first bit already centers it.
h1 {
text-align: center;
font-family: 'Roboto', sans-serif;
}
.robots {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.head,
.left_arm,
.torso,
.right_arm,
.left_leg,
.right_leg {
background-color: #5f93e8;
}
.head {
width: 200px;
margin: 0 auto;
height: 150px;
border-radius: 200px 200px 0 0;
margin-bottom: 10px;
}
.eyes {
display: flex;
align-items: center;
}
.head:hover {
width: 300px;
}
.upper_body {
width: 300px;
height: 150px;
display: flex;
}
.left_arm,
.right_arm {
width: 40px;
height: 125px;
border-radius: 100px;
}
.left_arm {
margin-right: 10px;
}
.right_arm {
margin-left: 10px;
}
.torso {
width: 200px;
height: 200px;
border-radius: 0 0 50px 50px;
}
.lower_body {
width: 200px;
height: 200px;
/* This is another useful property. Hmm what do you think it does?*/
margin: 0 auto;
display: flex;
justify-content: center;
}
.left_leg,
.right_leg {
width: 40px;
height: 120px;
border-radius: 0 0 100px 100px;
}
.left_leg {
margin-right: 30px;
}
.left_leg:hover {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(20deg);
}
.right_leg {
margin-left: 30px;
}
.right_leg:hover {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(340deg);
}
.left_eye,
.right_eye {
width: 20px;
height: 20px;
border-radius: 15px;
background-color: white;
}
.left_eye {
/* These properties are new and you haven't encountered
in this course. Check out CSS Tricks to see what it does! */
position: relative;
top: 100px;
left: 40px;
}
.right_eye {
position: relative;
top: 100px;
left: 120px;
}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<h1>Robot Friend</h1>
<div class="robots">
<div class="android">
<div class="head">
<div class="eyes">
<div class="left_eye"></div>
<div class="right_eye"></div>
</div>
</div>
<div class="upper_body">
<div class="left_arm"></div>
<div class="torso"></div>
<div class="right_arm"></div>
</div>
<div class="lower_body">
<div class="left_leg"></div>
<div class="right_leg"></div>
</div>
</div>
</div>

Simply try to position your eyes with margin- not with position- left:
.left_eye, .right_eye {
width: 20px;
height: 20px;
border-radius: 15px;
background-color: white;
margin: 0 auto; <-- make horizontal margin automatically
}
So it will still be centered even if you change element's width.

You can simply add this CSS code. (adjust the width as you need)
.eyes{
width:200px;
margin:0 auto;
}
h1 {
text-align: center;
font-family: 'Roboto', sans-serif;
}
.robots {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.head,
.left_arm,
.torso,
.right_arm,
.left_leg,
.right_leg {
background-color: #5f93e8;
}
.head {
width: 200px;
margin: 0 auto;
height: 150px;
border-radius: 200px 200px 0 0;
margin-bottom: 10px;
}
.eyes {
display: flex;
align-items: center;
}
.head:hover {
width: 300px;
}
.upper_body {
width: 300px;
height: 150px;
display: flex;
}
.left_arm,
.right_arm {
width: 40px;
height: 125px;
border-radius: 100px;
}
.left_arm {
margin-right: 10px;
}
.right_arm {
margin-left: 10px;
}
.torso {
width: 200px;
height: 200px;
border-radius: 0 0 50px 50px;
}
.lower_body {
width: 200px;
height: 200px;
/* This is another useful property. Hmm what do you think it does?*/
margin: 0 auto;
display: flex;
justify-content: center;
}
.left_leg,
.right_leg {
width: 40px;
height: 120px;
border-radius: 0 0 100px 100px;
}
.left_leg {
margin-right: 30px;
}
.left_leg:hover {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(20deg);
}
.right_leg {
margin-left: 30px;
}
.right_leg:hover {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(340deg);
}
.left_eye,
.right_eye {
width: 20px;
height: 20px;
border-radius: 15px;
background-color: white;
}
.left_eye {
/* These properties are new and you haven't encountered
in this course. Check out CSS Tricks to see what it does! */
position: relative;
top: 100px;
left: 40px;
}
.right_eye {
position: relative;
top: 100px;
left: 120px;
}
.eyes{
width:200px;
margin:0 auto;
}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<h1>Robot Friend</h1>
<div class="robots">
<div class="android">
<div class="head">
<div class="eyes">
<div class="left_eye"></div>
<div class="right_eye"></div>
</div>
</div>
<div class="upper_body">
<div class="left_arm"></div>
<div class="torso"></div>
<div class="right_arm"></div>
</div>
<div class="lower_body">
<div class="left_leg"></div>
<div class="right_leg"></div>
</div>
</div>
</div>

The eyes are relatively positioned. Try this, at the end of your CSS:
.head:hover .right_eye {
left: 170px;
}
.head:hover .left_eye {
left: 100px;
}

Related

(CSS) How to create a 3d element within another 3d element with CSS transforms?

I am learning React JS and also brushing up on some CSS styling. I have a small app that is basically a drum machine that I wanted to style to look as a launchpad using 3D transformations and CSS. The algorithm itself works, so I made the body of the launchpad, but I also wanted to make 3D buttons for it which would visually sink in when interacted with (either on click or key down). But I can't figure out how to make the buttons into cuboids that go on top of the main cuboid (the drumpad). They just remain flat in the top plane of the launchpad cuboid.
Codesandbox
Relevant JSX code:
The launchpad itself:
return (
<div className="drum-container">
<div className="drum-body">
<div id="drum-machine" className="side top">
<div className="drum-header">
<span>Beat Pro X</span>
<span>{clipName}</span>
</div>
<div id="display">
{keys.map((element, index) => {
return (
<Drumpad
key={element}
clip={clips[index]}
pressKey={element}
onClick={handleDrumpadClick}
onKeyDown={handleDrumpadClick}
/>
);
})}
</div>
</div>
<div className="side bottom"></div>
<div className="side left"></div>
<div className="side right"></div>
<div className="side front"></div>
<div className="side back"></div>
</div>
</div>
);
The Drumpad element:
return (
<div className="drumpad-button">
<div
ref={drumpadRef}
id={props.clip.name}
className="dpad-side dpad-top"
onClick={playAudio}
>
<span className="drum-pad-key">{props.pressKey}</span>
<audio ref={audioRef} className="clip" src={props.clip.source} />
</div>
<div className="dpad-side dpad-bottom"></div>
<div className="dpad-side dpad-left"></div>
<div className="dpad-side dpad-right"></div>
<div className="dpad-side dpad-front"></div>
<div className="dpad-side dpad-back"></div>
</div>
);
CSS:
* {
box-sizing: border-box;
}
body,
html {
margin: 0;
padding: 0;
background-color: darkgrey;
}
#root {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
}
.drum-container {
display: flex;
justify-content: center;
align-items: center;
border: 2px solid white;
border-radius: 4px;
height: 100%;
width: 100%;
perspective: 1500px;
perspective-origin: center;
}
.drum-body {
padding: 0;
margin: 0;
position: relative;
height: 700px;
width: 700px;
transform-style: preserve-3d;
transform: rotateX(-50deg);
}
.side {
border-radius: 15px;
position: absolute;
opacity: 0.9;
border: 2px solid white;
}
.front {
left: 100px;
top: 300px;
height: 100px;
width: 500px;
background-color: #d50000;
transform: translateZ(350px);
}
.back {
left: 100px;
top: 300px;
height: 100px;
width: 500px;
background-color: #aa00ff;
transform: translateZ(-350px);
}
.left {
top: 300px;
height: 100px;
width: 700px;
background-color: #304ffe;
transform: rotateY(90deg) translateZ(250px);
}
.right {
top: 300px;
height: 100px;
width: 700px;
background-color: #0091ea;
transform: rotateY(-90deg) translateZ(250px);
}
.top {
left: 100px;
height: 700px;
width: 500px;
background-color: #00bfa5;
transform: rotateX(90deg) translateZ(50px);
}
.bottom {
left: 100px;
height: 700px;
width: 500px;
background-color: #64dd17;
transform: rotateX(-90deg) translateZ(50px);
}
#display {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
row-gap: 20px;
column-gap: 20px;
padding: 0;
border: 0;
width: 80%;
margin: 200px auto 100px auto;
}
.drumpad-button {
border: 2px solid black;
position: relative;
padding: 0;
height: 120px;
width: 120px;
transform-style: preserve-3d;
transform: rotateX(30deg);
}
.dpad-side {
border-radius: 2px;
position: relative;
opacity: 0.9;
border: 2px solid white;
}
.dpad-front {
height: 20px;
width: 120px;
background-color: #d50000;
transform: translateZ(60px);
}
.dpad-back {
height: 20px;
width: 120px;
background-color: #aa00ff;
transform: translateZ(-60px);
}
.dpad-left {
height: 20px;
width: 120px;
background-color: #304ffe;
transform: rotateY(90deg) translateZ(60px);
}
.dpad-right {
height: 20px;
width: 120px;
background-color: #0091ea;
transform: rotateY(-90deg) translateZ(60px);
}
.dpad-top {
height: 120px;
width: 120px;
background-color: darkgreen;
transform: rotateX(90deg) translateZ(10px);
}
.dpad-bottom {
height: 120px;
width: 120px;
background-color: #64dd17;
transform: rotateX(-90deg) translateZ(10px);
}
Drumpads are in a grid, so I've tried setting the grid as the basis for the transform-style: preserve-3d, thinking that the grid elements as its children would then treat the top face of the launchpad as the base plane, but maybe there's something else I am doing wrong?
But from my understanding preserve-3d should be set on the element containing the elements that make up the figure in 3D space. When I change translateZ values I can see different planes popping up, but for some reason preserve-3d is ignored. Is it because of the grid? Or maybe specifics of the JSX nesting of imported components?

Strange bug with divs at same height overlapped with different z-index and with parent overflow hidden: border-bottom always is visible?

I created a speedometer that works very well and is to light (with CSS3,html and js code).
But i noticed a strange bug with iphone....
This is the CODE:
$('#first').addClass('first-start');
//SECOND BAR
$('#second').addClass('second-start');
setTimeout(function() {
$('#second').addClass('second-pause');
}, 400);
#page {
margin-top: 50px;
width: 300px;
height: 300px;
background-color: #000;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
z-index: 4;
overflow: hidden;
}
#box-first,
#box-second {
width: 200px;
height: 100px;
background-color: #fff;
border-radius: 200px 200px 0 0;
margin-top: 10px;
margin-bottom: 10px;
position: relative;
display: flex;
justify-content: flex-end;
align-items: flex-start;
z-index: 3;
overflow: hidden;
}
#first,
#second {
border-radius: 200px 200px 0 0;
margin: 0;
background: red;
width: 200px;
height: 100px;
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform-origin: 50% 100%;
-webkit-transform-origin: 50% 100%;
-moz-transform-origin: 50% 100%;
-ms-transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
#n1,
#n2 {
font-size: 20px;
color: #fff;
font-weight: bold;
position: absolute;
left: 50px;
right: 0;
text-align: center;
top: 50px;
bottom: 0;
display: flex;
align-items: flex-end;
justify-content: center;
width: 100px;
height: 50px;
background: #000;
border-radius: 100px 100px 0 0;
z-Index: 1;
overflow: hidden;
}
#keyframes first {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
#keyframes second {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
.first-start,
.second-start {
animation: first 2s linear forwards;
}
.first-pause,
.second-pause {
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="page">
<div id="box-first">
<div id="first"></div>
<div id="n1">1500</div>
</div>
<div id="box-second">
<div id="second"></div>
<div id="n2">270</div>
</div>
</div>
With iphone, so with safari, under (at the bottom side) div #n1 (the black div where there's number 1500) is visible a small white border or sometimes red (like #first).
And this is impossible because the container has overflow: hidden, all divs have different z-Index and the absolute position of #n1 is correct.
How is possibile ?
Thanks and sorry for my english
This is the jsfiddle: This is jsfiddle: https://jsfiddle.net/k85t9zgq/33/
This is a bug's screenshot:
THIS IS NEW "BUG" adding box-sizing:border-box
it seems to me that adding this new property not work the overflow:hidden property.
Is possible?
I cannot test this, but I am pretty sure it's related to the fact that background use background-clip border-box by default and this is somehow a rendring issue. A potential fix is to make the background far from the border by adding a small padding and adjusting background-clip
$('#first').addClass('first-start');
//SECOND BAR
$('#second').addClass('second-start');
setTimeout(function() {
$('#second').addClass('second-pause');
}, 400);
#page {
margin-top: 50px;
width: 300px;
height: 300px;
background-color: #000;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
z-index: 4;
overflow: hidden;
}
#box-first,
#box-second {
width: 200px;
height: 100px;
/* Changes*/
background: linear-gradient(#fff,#fff) content-box;
padding:1px;
box-sizing:border-box;
/**/
border-radius: 200px 200px 0 0;
margin-top: 10px;
margin-bottom: 10px;
position: relative;
display: flex;
justify-content: flex-end;
align-items: flex-start;
z-index: 3;
overflow: hidden;
}
#first,
#second {
border-radius: 200px 200px 0 0;
margin: 0;
background: red;
width: 200px;
height: 100px;
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform-origin: 50% 100%;
-webkit-transform-origin: 50% 100%;
-moz-transform-origin: 50% 100%;
-ms-transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
#n1,
#n2 {
font-size: 20px;
color: #fff;
font-weight: bold;
position: absolute;
left: 50px;
right: 0;
text-align: center;
top: 50px;
bottom: 0;
display: flex;
align-items: flex-end;
justify-content: center;
width: 100px;
height: 50px;
background: #000;
border-radius: 100px 100px 0 0;
z-Index: 1;
overflow: hidden;
}
#keyframes first {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
#keyframes second {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
.first-start,
.second-start {
animation: first 2s linear forwards;
}
.first-pause,
.second-pause {
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="page">
<div id="box-first">
<div id="first"></div>
<div id="n1">1500</div>
</div>
<div id="box-second">
<div id="second"></div>
<div id="n2">270</div>
</div>
</div>
I believe it's your border-radius property on #first and #second - Play around with the values on it and you will totally see what I mean.
Change this:
#first,
#second {
border-radius: 200px 200px 0 0; /* ← CHANGE THIS */
margin: 0;
background: red;
width: 200px; /* ← CHANGE THIS TOO */
height: 100px;
transform: rotate(180deg);
transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
to:
#first,
#second {
border-radius: 0; /* ← THIS IS WHAT YOU WANT */
margin: 0;
background: red;
width: 100%; /* ← THIS IS ALSO WHAT YOU WANT */
height: 100px;
transform: rotate(180deg);
transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
That faint white/gray line around your speedometer is no longer present.
Cheers and Happy coding :)

Position doesn't work on IE 11

I've tried several ways to code that supports IE - no success. See screenshot below to see the issues I'm showing.
position: relative; and position: absolute; in the parent in css didnt work.
First several lines shows -
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="X-UA-Compatible" content="IE=11">
HTML
<div class="notice-wrapper">
<div class="notice-overlay">
<div class="notices">
<div class="box-left">
<img src="imgs/check.png" alt="Everything is Good! - Sorenson VRS">
<p class="good">EVERYTHING IS GOOD!</p>
</div>
<div class="box-right"><h1>Service Outage</h1><p>Sorenson is not experiencing any service outage at this time. If you are experience problems connecting to VRS, please restart the Sorenson endpoint (VP, PC, or Mobile device). if you continue to have problems, please contact Tech Support below.</p></div>
</div>
</div>
</div>
<div class="service-wrapper">
<div class="services">
<div class="button"><img src="imgs/icon-techsup.png" class="iconBtn"> TECHNICAL SUPPORT</div>
<div class="text"><p>For technical issues with placing or receiving videophone calls.</p></div>
</div>
<div class="services">
<div class="button"><img src="imgs/icon-custserv.png" class="iconBtn"> CUSTOMER SERVICES</div>
<div class="text2"><p>For questions about applying for ntouch®, porting, moving, updating your address, or other general questions.</p></div>
</div>
</div>
<div class="video-wrapper">
<div class="title-video"><h2>(title here)</h2></div>
<div class="video"><img src="imgs/video-placeholder.png" alt="video"></div>
<div class="bg-orange"></div>
<div class="bg-white-watermark"></div>
<div class="bg-white"></div>
</div>
CSS with the Everything is Good boxes -
.notice-wrapper {
height: 400px;
width: 100%;
}
.notice-overlay {
display: block;
width: 100%;
height: 400px;
position: relative;
background: rgba(0,0,0,0.8);
left: 0;
z-index: 9999;
color: #fff;
overflow: hidden;
text-align: center;
}
.notices {
display: flex;
width: 809.25px;
height: 288.25px;
text-align: center;
vertical-align: middle;
overflow: hidden;
margin: 0 auto;
position: relative;
transform: translateY(60px)
-ms-transform: translateY(60px);
-webkit-transform: translateY(60px);
}
.box-left {
flex: 1;
background: #41ad49;
height: 100%;
padding-top: 35px;
}
.box-right {
width: 450px;
background: #40403f;
padding: 25px;
text-align: left;
}
CSS for the two buttons and the texts -
.service-wrapper {
width: 100%;
height: 175px;
background-color: #000000;
}
.services {
width: 55%;
display: flex;
margin: 0 auto;
transform: translateY(15px)
-ms-transform: translateY(25px);
-webkit-transform: translateY(15px);
}
.text p {
flex: 1 1 auto;
line-height: 25px;
font-size: 16px;
color: #ffffff;
text-align: left;
align-items: center;
transform: translateY(6px)
-ms-transform: translateY(6px);
-webkit-transform: translateY(6px);
}
.text2 p {
flex: 1 1 auto;
line-height: 25px;
font-size: 16px;
color: #ffffff;
text-align: left;
align-items: center;
transform: translateY(6px)
-ms-transform: translateY(6px);
-webkit-transform: translateY(6px);
}
.button {
flex: 0 0 auto;
height: 40px;
width: 225px;
margin: 10px;
padding: 5px;
padding-right: 15px;
padding-left: 15px;
border-radius: 5px;
background: #ffbb11;
text-align: center;
color: #000000;
font-weight: bold;
display: flex;
align-items: center;
justify-content: space-around;
}
.iconBtn{
max-height: 75%;
max-width: 75%;
}
CSS on title and the image -
.title-video h2 {
width: 100%;
position: absolute;
margin: auto 0;
text-align: center;
margin-top: 50px;
transform: translateX(-285px)
-ms-transform: translateX(-285px);
-webkit-transform: translateX(-285px);
}
.video-wrapper {
width: 100%;
margin: auto 0;
text-align: center;
}
.video {
position: absolute;
margin: auto 0;
text-align: center;
width: 100%;
}
.video img {
max-height: 75%;
max-width: 75%;
width: 700px;
height: 393px;
margin-top: 90px;
}

drawing shapes with css

Am trying to get a shape drawn in css on the header of my webpage. it supposed to look like this.
The shape am trying to draw for my header
but when I try to get the exact shape, IT looks like this below (Run the snippet)
Am not so good at css so am struggling here. The codes are below.
header {
padding: 0px !important;
height: auto !important;
}
.header {
top: 0px;
width: 100%;
height: auto !important;
padding: 0px !important;
background-color: #00ff00;
}
.spanheader {
font-size: 20px;
}
.logo {
z-index: 1;
position: relative;
}
.topheader {
text-align: center;
width: 100%;
background-color: lightgray;
left: 0px !important;
top: 0px !important;
}
#draw {
height: 30px;
width: 100%;
background-color: #fff;
}
#green {
height: 60px;
width: 100%;
border-width: 0px;
border-left: 280px solid white;
border-top: 20px solid white;
-moz-transform: skew(-45deg);
-webkit-transform: skew(-45deg);
transform: skew(-45deg);
}
<section id="header" class="header">
<div class="topheader">
<span class="spanheader f-700 c-gray">HEADER</span>
</div>
<div id="draw"></div>
<div id="green"></div>
</section>
What Am trying to achieve with my header and shape drawing
final look I want to achieve or what it should should look like at the end
You can just create a small white rectangle at the left top, skew it and move it a little to the left to remove the green triangle:
.green {
background-color:#0f0;
height:60px;
width:100%;
}
.draw {
height:30px;
margin-left:-15%;
width:30%;
background-color:#fff;
-moz-transform: skew(-45deg);
-webkit-transform: skew(-45deg);
transform: skew(-45deg);
}
<div class="green">
<div class="draw">
</div>
</div>
Try using :after. See this snippet.
header {
padding: 0px !important;
height: auto !important;
}
.header {
top: 0px;
width: 100%;
height: auto !important;
padding: 0px !important;
background-color: #00ff00;
}
.spanheader {
font-size: 20px;
}
.logo {
z-index: 1;
position: relative;
}
.topheader {
text-align: center;
width: 100%;
background-color: lightgray;
left: 0px !important;
top: 0px !important;
}
#draw {
height: 30px;
width: 100%;
background-color: #fff;
}
#green {
height: 60px;
width: 100%;
border-width: 0px;
position:relative;
}
#green:after{
content:'';
position:absolute;
top:0;
left:-25px;
height:30px;
width:250px;
background:white;
-moz-transform: skew(-60deg);
-webkit-transform: skew(-60deg);
transform: skew(-60deg);
}
<html>
<!--[if IE 9 ]><html class="ie9"><![endif]-->
<!-- Mirrored from byrushan.com/projects/ma/1-6-1/jquery/light/login.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 14 Jun 2016 14:12:13 GMT -->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WEBPAGE </title>
</head>
<body>
<section id="header" class="header">
<div class="topheader">
<span class="spanheader f-700 c-gray">HEADER</span>
</div>
<div id="draw">
</div>
<div id="green"></div>
</section>
</body>
</html>
Take a look at this JSFiddle
header{
text-align:center;
padding: 5px 0;
background: grey;
color: white;
}
footer{
text-align: center;
padding: 50px 0;
position: relative;
}
footer::before,footer::after{
content: '';
display: inline-block;
width: 70%;
height: 50px;
background: green;
position: absolute;
bottom: 0;
right: -10px;
transform: skewX(-30deg);
}
footer::after{
width: 100%;
height: 30px;
transform: skewX(0);
}
#header {
width: 100%;
height: 30px;
background: #CCC;
text-align: center;
line-height: 30px;
}
#slashWrapper {
position: relative;
background: #FFF;
width: 100%;
height: 100px;
}
#whiteSlash {
height: 75px;
width: 300px;
background: #FFF;
position: absolute;
top: 0px;
-moz-transform: skew(-45deg);
-webkit-transform: skew(-45deg);
transform: skew(-45deg);
z-index: 2;
}
#greenSlash {
height: 50px;
width: 100%;
position: absolute;
bottom: 0px;
background: #00ff00;
}
#whiteSlashBottomCorner {
height: 25px;
width: 25px;
background: #FFF;
position: absolute;
bottom: 0px;
right: -25px;
-moz-transform: skew(-45deg);
-webkit-transform: skew(-45deg);
transform: skew(-45deg);
z-index: 2;
}
<div id="header">HEADER</div>
<div id="slashWrapper">
<div id="whiteSlash"></div>
<div id="greenSlash"></div>
<div id="whiteSlashBottomCorner">
</div>

CSS - Prevent font-family and letter spacing from changing margin on div and ul

I have a container containing a rotated div and an unordered list. I'm trying to get the div and the list flush with one another. I'm able to do this by changing the margin on the div and/or the unordered list. However, when I change the font-family or letter-spacing of the entire document it changes the spacing between the div and ul.
http://jsfiddle.net/
Open the fiddle and use the inspector to toggle the letter-spacing property on * to see what I mean visually.
#container {
z-index: 2147483645;
height: 400px;
width: 400px;
background-color: grey;
display: inline-block;
position: fixed;
}
#tab {
background-color: #9F8F6C;
display: inline-block;
vertical-align: top;
height: 100%;
width: 40px;
padding: 0;
margin: 0;
}
#tab a {
position: fixed;
width: 400px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg) translateX(-100%);
transform-origin:left top;
font-size: 18px;
cursor: pointer;
text-align: center;
color: #F5F5F5;
text-decoration: none;
padding: 0;
margin: 0;
}
#my-list {
background-color:rgba(255,255,255,0.5);
display: inline-block;
vertical-align: top;
height: 100%;
width: 65px;
padding: 0;
margin: 0;
}
* {
letter-spacing: 2px;
}
<div id='container'>
<div id='tab'>
<a id='tab-text'>hellloooo</a>
</div>
<ul id='my-list'>
</ul>
</div>
If I understood correctly, you just need to change your letter-spacing from * to tab.
For demo purposes I replaced your ID's for classes(because a ID[#], must be unique in the code) .
So here is a snippet below:
#container {
z-index: 2147483645;
height: 400px;
width: 400px;
background-color: grey;
display: inline-block;
position: fixed;
}
.tab {
background-color: #9F8F6C;
display: inline-block;
vertical-align: top;
height: 100%;
width: 40px;
padding: 0;
margin: 0;
/*letter-spacing:2px APPLY HERE */
}
.tab a {
position: fixed;
width: 400px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg) translateX(-100%);
transform-origin: left top;
font-size: 18px;
cursor: pointer;
text-align: center;
color: #F5F5F5;
text-decoration: none;
padding: 0;
margin: 0;
}
#my-list {
background-color: rgba(255, 255, 255, 0.5);
display: inline-block;
vertical-align: top;
height: 100%;
width: 65px;
padding: 0;
margin: 0;
}
/*DEMO PURPOSES*/
.letter-spacing {
letter-spacing: 2px
}
<div id='container'>
<div class='tab letter-spacing'>
<a class='tab-text'>hellloooo</a>
</div>
<div class='tab'>
<a class='tab-text'>hellloooo</a>
</div>
<ul id='my-list'>
</ul>
</div>