CSS Styling fort Fluid Width - html

My site here is fluid width, but the middle header section with the search bar and image doesn't resize correctly in either IE, Chrome or FF.
I've tried using media screen stylesheets for lower screen resolutions, but this just causes there to be a gap to the right of the right-hand image in some browsers where they display the width differently.
If anyone could possibly take a look and see it at different resolutions and browsers that would be great, and perhaps help with any suggestions.
Currently in IE9, when it's reduced slightly under 1263px (approx 1250px), the image jumps down entirely and looks awful.
Here's the CSS:
/*Town Image */
#town-image-search {
box-shadow:0 5px 5px #CCC;
background:0;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fafafa',endColorstr='#e4e4e4');
border-top:1px solid #D6D2D5;
border-bottom:#d1d1d1;
}
#search-bar {
float:left;
width:16.5%;
padding:8px 15px;
}
input#search {
width:100%;
height:22px;
color:#aaa;
text-indent:10px;
border:1px solid #d6d6d6;
font-size:14px;
-webkit-border-bottom-left-radius:5px;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
margin:0 0 6px;
padding:0;
}
input#submit {
width:100%;
border:1px solid #666;
height:22px;
color:#fff;
text-shadow:0 1px 0 #555;
background-color:#803C6D;
font-family:'Arial Rounded MT Bold';
cursor:pointer;
-webkit-border-top-right-radius:5px;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
padding:0;
}
#middle-top {
height:68px;
float:left;
width:81%;
border-left:1px solid #Fafafa;
}
#town-name {
word-spacing:5px;
position:relative;
z-index:0;
float:left;
font-family:'arial rounded mt bold';
font-size:36px;
color:#354057;
line-height:69px;
text-indent:27px;
letter-spacing:-3px;
}
#town-name span {
font-family:'arial rounded mt bold';
color:#354057;
}
img#heart {
float:right;
width:230px;
height:68px;
position:relative;
z-index:10;
margin-right:-120px;
}
img#town-image {
width:404px;
height:68px;
float:right;
}
Any ideas would be much appreciated.

#middle-top a float:right and changed the width to 80%

Related

How to cut out unnecessary extra coding for CSS/HTML and make it more responsive?

Afternoon all ( or evening/morning/night ). I'm looking a slight push in the right direction regarding a project of mine. This layout is for tumblr ( not an actual page for a company so please don't yell at me ), and it's my first code that I've managed to make. The problem is that right after making it, I noticed how... poorly it was made. I use too much padding, margins, and other nonsense that could be cut out.
I desperately wanted to try and rewrite the code, using percentages, rems/ems, vh/vw, etc while still keeping the layout/design 100% intact. The problem, however, is that I wouldn't know how to begin, exactly, or what to even cut out, while still keeping the spacing and such intact. For example, say I want to completely eliminate pixel measurements for my post container ( .pc ), how do I ensure it remains in that same exact spot ( at least on screens that share my same viewport measurement ) with those margins, while using say, percentages? How do I even measure a div container in percentages or even vw/vh to begin with?
Please know that I'm not trying to have someone do this for me, or anything like that. I just want to have a nudge in the proper direction where I can start. Here's my code: https://pastebin.com/q5cFtVQP and a snippet:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, width=device-width"/>
<!-- BROWSER TITLE -->
<title>𝐃𝐄𝐌𝐄𝐓𝐄𝐑 .</title>
<!-- END OF BROWSER TITLE -->
<!-- BROWSER ICON -->
<link rel="shortcut icon" href="https://66.media.tumblr.com/e948812964cb16505f4cd4f894344288/672e88b582120b94-84/s540x810/9301ad0a7a1dc0235256ca2aa89738258b0383a5.png">
<!-- END OF BROWSER ICON -->
<!-- FONTS -->
<link href="https://fonts.googleapis.com/css2?family=Bowlby+One&display=swap" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,400italic,900,700,700italic,500italic,500' rel='stylesheet' type='text/css'>
<!-- END OF FONTS -->
<style type="text/css">
/* PULSE ANIMATION */
.pulsate { -webkit-animation: pulsate 2s ease-out;
-webkit-animation-iteration-count: infinite;
opacity: 0.5; }
#-webkit-keyframes pulsate { 0% { opacity: 0.5; }
50% { opacity: 1.0;}
100% { opacity: 0.5; } }
/* END OF PULSE ANIMATION */
/* FOLLOW BUTTONS */
.iframe-controls--desktop { position:fixed;
top:0px;
right:0px;
z-index:214748364789123456789;
-filter:invert(100%);
-webkit-filter:invert(100%);
-webkit-transform:scale(0.6,0.6);
-webkit-transform-origin: 100% 0%;
-ms-transform-origin:100% 0%;
-ms-transform:scale(0.6,0.6);
transform:scale(0.6,0.6);
transform-origin:100% 0%; }
/* END OF FOLLOW BUTTONS */
/* SELECTION */
::selection { background:#ff40f3; }
::-moz-selection { background:#ff40f3; }
/* END OF SELECTION */
/* SCROLLBAR */
::-webkit-scrollbar-thumb { background:#ff62f5;
border-radius:25px;linear-gradient(to bottom, #b1e0f5 , #ffc4f6);
width:8px;
height:5px; }
::-webkit-scrollbar { background:#292929;
border-radius:25px;
height:5px;
width:8px; }
/* END OF SCROLLBAR */
/* EMBEDS */
embed, object, video { max-width: 200px; }
img { max-width:180px;
height:auto;
width:auto; }
/* END OF EMBEDS */
/* BLOG STYLINGS */
html { background-color:#e6eaeb;
color:#e6eaeb;
font-family:'Roboto', sans-serif;
font-size:11px;
text-align:left;
word-spacing:3px;
text-transform:uppercase; }
.tc a:hover, .nav a:hover, .pagc a:hover,#mybtn:hover { cursor: pointer;
color: #ff62f5;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out; }
.posts a:hover, .pnc a:hover { color: #ff62f5;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out; }
.divider { border-top: 6px solid #02afff;
border-radius:5px;
margin:auto;
width:80%; }
pre, small, sup, sub { font-size:1rem;
font-family:'Roboto', sans-serif; }
blockquote { border-left:4px solid;
color:#ff62f5;
padding-left:5px;
margin-left:3px;
width:94%; }
blockquote p { font-family:'Roboto', sans-serif;
color:#efefef; }
blockquote blockquote { margin-left:1px; }
h3 { text-transform:uppercase;
color:#ff62f5;
text-align:center;
font-family:'Bowlby One', cursive;
font-size:1.5rem;
letter-spacing:1px; }
h1, h2 { color:#02afff;
text-decoration:none;
line-height:25px;
padding-bottom:2px;
font-family:'Bowlby One', cursive;
text-align:center;
text-transform:uppercase;
font-size:2rem;
margin-top:10px;
margin-right:15px;
background-color:#313131;
box-shadow: 0 -4px #ff62f5 inset; }
p { font-family:'Roboto', sans-serif; }
b, strong { color:#02afff; }
i { color:#ff62f5;
font-style:normal; }
/* END OF BLOG STYLINGS */
/* READ MORE BUTTON */
#more { color:#e6eaeb;
text-decoration:none;
display:inline-block;
font-family:'Bowlby One', cursive;
font-size:1rem;
text-transform:uppercase;
text-align:center;
padding:2px;
background-color:#ff62f5;
border-radius:25px; }
#more:hover { color:#02afff;
cursor: pointer; }
/* END OF READ MORE BUTTON */
/* SCROLL TO TOP BUTTON */
#stt { position: fixed; /* Fixed/sticky position */
z-index:99999999999999;
display: none; /* Hidden by default */
top:613px; /* Place the button at the bottom of the page */
left:1029px; /* Place the button 30px from the right */
border: none; /* Remove borders */
outline: none; /* Remove outline */
font-family:'Bowlby One', cursive;
background-color: #02afff; /* Set a background color */
color:#e6eaeb;
cursor: pointer; /* Add a mouse pointer on hover */
padding:6px;
border-radius:15px; /* Rounded corners */
text-transform:uppercase;
text-align:center;
font-size:1rem; /* Increase font size */ }
/* END OF SCROLL TO TOP BUTTON */
/* PERMALINK PAGE */
.permc { margin-top:5px;
margin-left:18px;
left:368px;
width:387px;
max-height:220px;
background-color:#252525;
overflow-x:hidden;
border-left:25px solid #ff62f5; }
.permc p, .permc a { color:#ff62f5;
margin:0 auto;
margin-top:0px;
text-decoration:none;
display:inline-block;
font-family:'Bowlby One', cursive;
font-size:1rem;
text-transform:uppercase; }
.permc img.avatar { display:none; }
.permc li { list-style-type:none;
margin:0;
padding:0; }
/* END OF PERMALINK PAGE */
/* MAIN TITLE */
.mtc { margin-top:45px;
margin-bottom:45px;
position:absolute;
z-index:1;
left:385px;
width:648px;
height:96px;
background-color:#252525;
border-left:25px solid #ff62f5;
padding:0 -15px -40px 0;
-webkit-box-shadow: 0px 5px 10px 1px rgba(0,0,0,0.39);
-moz-box-shadow: 0px 5px 10px 1px rgba(0,0,0,0.39);
box-shadow: 0px 5px 10px 1px rgba(0,0,0,0.39); }
.mt { font-family: 'Bowlby One', cursive;
color:#e6eaeb;
text-indent:20px;
font-size:5.9rem;
text-shadow:3px 5px 1px #6bb6fa; }
/* END OF MAIN TITLE */
/* POSTS */
.pc { position:absolute;
padding-top:98px;
padding-bottom:6px;
top:14px;
left:368px;
width:445px;
min-height:450px;
margin-bottom:15px;
background-color:#313131;
border-top:15px solid #02afff;
border-bottom:15px solid #02afff;
-webkit-box-shadow: 0px 5px 10px 1px rgba(0,0,0,0.39);
-moz-box-shadow: 0px 5px 10px 1px rgba(0,0,0,0.39);
box-shadow: 0px 5px 10px 1px rgba(0,0,0,0.39); }
.posts { width:375px;
font-weight:900;
max-height:350px;
min-height:150px;
margin-top:5px;
margin-left:18px;
padding-left:10px;
left:368px;
background-color:#252525;
overflow-x:hidden;
overflow-y:auto;
border-left:25px solid #ff62f5; }
.posts a { text-decoration:none;
box-shadow:0 -4px #ff62f5 inset;
font-family: 'Bowlby One', cursive;
color:#02afff;
padding-bottom:5px;
font-size:1rem; }
/* END OF POSTS */
/* POST TITLE */
.ptc { width:375px;
margin-top:5px;
margin-left:18px;
padding-left:10px;
left:368px;
background-color:#252525;
border-left:25px solid #ff62f5; }
.pt { color:#e6eaeb;
text-decoration:none;
line-height:35px;
padding-bottom:5px;
font-family:'Bowlby One', cursive;
text-align:center;
text-transform:uppercase;
font-size:2.8rem;
padding-top:5px;
margin-right:15px;
text-shadow:3px 3px 1px #6bb6fa }
/* END OF POST TITLE */
/* POST TAGS */
.tc { width:367px;
padding-left:10px;
padding-right:10px;
margin-left:18px;
margin-top:5px;
background-color:#252525;
border-left:25px solid #ff62f5; }
.tc a { color:#e6eaeb;
text-decoration:none;
display:inline-block;
font-family:'Bowlby One', cursive;
font-size:1rem;
text-transform:uppercase;
text-align:center;
margin-top:5px;
margin-bottom:5px;
padding:4px;
background-color:#02afff;
border-radius:25px; }
/* END OF POST TAGS */
/* NAVIGATION CONTAINER + NAVIGATION */
.navc { position:fixed;
top:547px;
left:818px;
width:242px;
min-height:32px;
background-color:#313131;
border-top:15px solid #02afff;
border-bottom:15px solid #02afff; }
.nav { display:inline block;
width:67px;
float:left;
height:24px;
margin-top:4px;
margin-left:2px;
background-color:#252525;
border-left:10px solid #ff62f5; }
.nav a { text-decoration:none;
font-family: 'Bowlby One', cursive;
color:#e6eaeb;
text-align:center;
font-size:1.3rem;
margin-left:4px;
margin-top:3px;
text-shadow:2px 1px 1px #0081bd; }
/* END OF NAVIGATION */
/* PAGINATION */
.pagc { position:fixed;
top:613px;
left:818px;
max-width:148px;
height:15px;
padding:7px;
background-color:#02afff;
border-radius:25px; }
.pagc a { color:#e6eaeb;
font-size:.9rem;
text-decoration:none;
font-family: 'Bowlby One', cursive; }
/* END OF PAGINATION */
/* SIDEBAR 1 + CONTAINER */
.sbc1 { position:fixed;
top:155px;
left:818px;
width:242px;
height:327px;
background-color:#313131;
border-top:15px solid #02afff;
border-bottom:15px solid #02afff;
overflow-y:auto;
z-index:1; }
.sb1 { margin-right:10px;
margin-left:10px;
font-weight:900; }
/* END OF SIDEBAR 1 + CONTAINER */
/* POSTNOTES */
.pnc { width:250px;
height:45px;
background-color:#252525;
padding-left:10px;
margin-left:18px;
line-height:2.8;
margin-top:35px;
border-left:25px solid #ff62f5; }
.pnc a { text-decoration:none;
color:#02afff;
font-family: 'Bowlby One', cursive;
font-size:.9rem;
display:inline-block;
text-transform:uppercase;
text-align:center;
box-shadow:0 -4px #ff62f5 inset; }
/* END OF POSTNOTES CONTAINER */
/* MODAL POPUP */
/* MODAL OPEN BUTTON */
#mybtn { width:242px;
position:fixed;
height:26px;
background-color:#02afff;
border:none;
top:516px;
left:818px;
font-size:1.6rem;
color:#e6eaeb;
font-family: 'Bowlby One', cursive; }
button:focus { outline: none; }
/* END OF MODAL OPEN BUTTON */
/* MODAL BOX */
.modal { display:none; /* Hidden by default */
position:fixed; /* Stay in place */
z-index:9999999999999999999; /* Sit on top */
padding-top:50px; /* Location of the box */
left:0;
top:0;
overflow-y:auto;
width:100%; /* Full width */
height:100%;
background-color:rgb(0,0,0); /* Fallback color */
background-color:rgba(0,0,0,0.95); /* Black w/ opacity */ }
/* END OF MODAL BOX */
/* MODAL CONTENT */
.modal-content { position: relative;
background-color: #313131;
margin:auto;
overflow-y:auto;
padding:0;
border-top:15px solid #02afff;
border-bottom:15px solid #02afff;
width:680px;
max-height:85%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,1);
-webkit-animation-name:zoom;
-webkit-animation-duration:0.4s;
animation-name:zoom;
animation-duration: 0.4s }
.modal-body { padding: 5px 26px;
font-size:1rem;
font-weight:900;
color:#e6eaeb; }
/* END OF MODAL CONTENT */
/* MODAL ANIMATION */
#keyframes zoom {0% {transform: scale(1,1);}
50% {transform: scale(1.2,1.2);}
100% {transform: scale(1,1);} }
/* END OF MODAL ANIMATION */
/* MODAL CLOSE BUTTON */
.close { color:#e6eaeb;
width:85px;
text-decoration:none;
font-family:'Bowlby One', cursive;
font-size:1rem;
text-transform:uppercase;
text-align:center;
margin:0 auto;
margin-top:2%;
padding:4px;
background-color:#02afff;
border-radius:25px; }
.close:hover { cursor: pointer;
color: #ff62f5;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out; }
/* END OF MODAL CLOSE BUTTON */
/* END OF MODAL POPUP */
/* SVG GRAPHICS */
/* BOTTOM WAVE */
#wave { position:fixed;
z-index:-100;
width:100%;
bottom:-3px;
background-repeat:repeat-x;
left: 0px;
right: 0px; }
/* END OF BOTTOM WAVE */
/* RIGHT BLOB */
#blob1 {position:fixed;
margin:auto;
left:860px;
top:80px;
bottom:0px;
width:500px;
height:515px;
overflow: hidden; }
#blob1stroke {position:fixed;
margin:auto;
stroke:#ffa6f9;
stroke-width:1px;
transform:rotate(10deg);
left:860px;
top:80px;
bottom:0px;
width:500px;
height:515px;
overflow: hidden; }
/* END OF RIGHT BLOB */
/* LEFT BLOB */
#blob2 { position:fixed;
margin:auto;
left:50px;
top:-80px;
z-index:-2;
bottom:0px;
width:500px;
height:515px;
overflow: hidden; }
#blob2stroke { position:fixed;
margin:auto;
left:50px;
top:-80px;
z-index:-2;
stroke:#ffa6f9;
stroke-width:1px;
transform:rotate(10deg);
bottom:0px;
width:500px;
height:515px;
overflow: hidden; }
/* END OF LEFT BLOB */
</style>
( here's a live demo, if that matters: https://kittycodes-preview.tumblr.com/ )
Any help is appreciated! ( note: before anyone wants to point out the 'incorrect' layout; Tumblr is very unorthodox with its' coding layout setup. The css and html go together and use exclusive blocks for posts and such, and it would actually look broken if you try to deploy the code in of itself ).
I use too much padding, margins, and other nonsense that could be cut
out.
Why do you think that padding and margins are nonsense? What is the "other" nonsense you're referring to? I've never built a website or a view in a web application that didn't use padding and margin to some extent.
I desperately wanted to try and rewrite the code, using percentages,
rems/ems, vh/vw, etc while still keeping the layout/design 100%
intact.
Is this because you read a medium article that said you should use those units? Different units are useful in different situations.
For example, say I want to completely eliminate pixel measurements for
my post container ( .pc ), how do I ensure it remains in that same
exact spot ( at least on screens that share my same viewport
measurement ) with those margins, while using say, percentages?
Why do you need to eliminate pixel measurements? There's nothing inherently wrong with pixels. It depends on the situation and what you're trying to accomplish.
How do I even measure a div container in percentages or even vw/vh to
begin with?
Honestly it seems like you haven't done any reading or made much of an effort to eduacate yourself. These are extremely basic things you're asking and you're going to have a much easier time finding the answers yourself by just learning how to write code. That being said you measure a div in percentages the same way you measure anything in percentages...100% is the entirety...50% is half...etc.
I could see why view port units versus percentages could cause a little confusion.
width: 100vw is equal to 100% of the width of the users' screen.
width: 100% is equal to 100% of the element's parent's width.
I suggest you start somewhere like w3schools.com to start building a basic foundation of knowledge you need to answer the questions that you have.

How should I make a button higher without effecting other elements?

I have a navigation bar at the top of my website.
HTML:
<text align="center">
<div class="home-nav">
<button class="nav-btn">What's New</button>
<button class="nav-btn">Community</button>
<button class="play-btn">Coming Soon</button>
<button class="nav-btn">Profile</button>
<button class="nav-btn">Information</button>
</text>
CSS:
.home-nav {
width:1240px;
height:49px;
background-color:#F1B84E;
border:5px solid #FFDE84;
border-style:outset;
}
.nav-btn {
width:auto;
height:49px;
background-color:#F1B84E;
border:none;
font-family:showcard gothic;
color:white;
-webkit-text-stroke:1.25px #000000;
-webkit-text-fill-color:#FFFFFF;
font-size:20px;
}
.play-btn {
width:auto;
height:69px;
background-color:#79E119;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border:5px solid #FFFFFF;
font-size:20px;
font-family:showcard gothic;
color:white;
}
I want the play button to be bigger than the normal buttons. But when I make the height higher than the normal buttons and look at it, it makes the normal buttons change position. How can I fix this?
Ok I have bring some small changes to your CSS styling just try these and let me know its working as you wanted or not.
body{
margin:0; padding:0;
}
.home-nav {
width:90%;
margin: 0 auto;
display: block;
background-color:#F1B84E;
border:5px solid #FFDE84;
border-style:outset;
}
.nav-btn {
width:auto;
height:49px;
background-color:#F1B84E;
border:none;
font-family:showcard gothic;
color:white;
-webkit-text-stroke:1.25px #000000;
-webkit-text-fill-color:#FFFFFF;
font-size:20px;
}
.play-btn {
width:auto;
height:70px;
background-color:#79E119;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border:5px solid #FFFFFF;
font-size:20px;
font-family:showcard gothic;
color:white;
}

CSS conflict in backgrounds and border

Whilst designing a page i come across a conflict (i guess) in a div that holds a group of divs.
How it currently looks http://castellvmaqvae.nl/exposities/
img is how it should look. enter image description here
Change the following, your div inside the main div are wider than they should be, which in your case you want them the same width as the image, here is the updated CSS :
.col-md-4 third {
width:25%; //You may want to play around with this on different screen sizes
}
OR FIXED WIDTH:
.col-md-4 third {
width:200px; // Same width as the picture
}
Somehow the wrappers background color has no effect but giving background color to the individual divs and borders seem to work great.
code:
.verwikkeld {width:316px;
height:auto;
background-color: #FFF;
border:#999 1px solid;
margin-left:20px;
margin-right:30px;
}
.verwacht{color:#666;
border-left:#000 1px solid;
border-right:#000 1px solid;
border-top:#000 1px solid;
width:220px;
background-color:#FFF;
text-align:center;
font-family:Arial, Helvetica, sans-serif;
padding-top:10px;
padding-bottom:10px;
font-size:32px;
}
.verwacht_img{border-left:#000 1px solid;
border-right:#000 1px solid;
background-color:#FFF;
width:220px;
}
.verwacht_naam{color:#666;
border-left:#000 1px solid;
border-right:#000 1px solid;
background-color:#FFF;
width:220px;
font-family:Arial, Helvetica, sans-serif;
padding-left:10px;
padding-top:10px;
font-size:28px;
}
.verwacht_titel{color:#000;
border-left:#000 1px solid;
border-right:#000 1px solid;
background-color:#FFF;
width:220px;
font-family:Arial, Helvetica, sans-serif;
padding-left:10px;
padding-top:10px;
font-size:16px;
}
.verwacht_datum{color:#F90;
border-left:#000 1px solid;
border-right:#000 1px solid;
background-color:#FFF;
width:220px;
font-family:Arial, Helvetica, sans-serif;
padding-left:10px;
padding-top:10px;
font-size:12px;
}
.verwacht_text{color:#000;
border-left:#000 1px solid;
border-right:#000 1px solid;;
border-bottom:#000 1px solid;
background-color:#FFF;
width:220px;
font-family:Arial, Helvetica, sans-serif;
padding-left:10px;
padding-top:10px;
padding-bottom:20px;
font-size:12px;
}
Thank you guys for your time.
Just do this modify:
`col-md-2` --> `col-md-1`
`col-md-6` --> `col-md-7 second`
`col-md-4 third` --> `col-md-3 third`
Also in the existing, add text-align: center; to col-md-3 third.
I hope this is what you want.

Display two divs inline

I need to display two divs one next to another on the same line, but I can't understand why the second one is slightly lower than the first one.
<div class="cont-title">
<div class="triang-header"></div>
<div class="h2-stripe">
<h2 itemprop="name">
Title
</h2>
</div>
</div>
This is the css:
.cont-title{
margin-right: -7px;
min-width: 90%;
max-width: 100%;
height:51px;
float:right;
text-align:right;
white-space: nowrap;
}
.triang-header{
position:relative;
width:39px;
height:38px;
display:inline-block;
background:url('../images/titlebar.png') no-repeat top left;
}
.h2-stripe{
position:relative;
z-index:10;
display:inline-block;
text-align:left;
background-color: #2A58AE;
margin:0;
height:38px;
min-width:80%;
line-height:38px;
box-shadow: 2px 3px 5px 0 #555;
}
What am I doing wrong?
I think you did not count the line-height,
should be like this the style for .h2-stripe:
.h2-stripe{
position:relative;
line-height: 23px; // <----
z-index:10;
display:inline-block;
text-align:left;
background-color: #2A58AE;
margin:0;
height:38px;
min-width:80%;
box-shadow: 2px 3px 5px 0 #555;
}
here it is an example with line-height:23px for .h2-stripe: http://jsfiddle.net/6a0ga3uq/
you misspelled your class
.h2-strispe{
position:relative;
z-index:10;
display:inline-block;
text-align:left;
background-color: #2A58AE;
margin:0;
height:38px;
min-width:80%;
line-height:38px;
box-shadow: 2px 3px 5px 0 #555;
}
should be
.h2-stripe{
position:relative;
z-index:10;
display:inline-block;
text-align:left;
background-color: #2A58AE;
margin:0;
height:38px;
min-width:80%;
line-height:38px;
box-shadow: 2px 3px 5px 0 #555;
}
The margin of your h2 element causes the second div to shift down. Also, you should vertical-align inline-block elements. See this updated snippet (also with corrected class name in CSS).
.cont-title{
margin-right: -7px;
min-width: 90%;
max-width: 100%;
height:51px;
float:right;
text-align:right;
white-space: nowrap;
}
.cont-title > * {
vertical-align: middle;
}
.triang-header{
position:relative;
width:39px;
height:38px;
display:inline-block;
background:url('http://placehold.it/39x38') no-repeat top left;
margin: 0;
}
.h2-stripe{
position:relative;
z-index:10;
display:inline-block;
text-align:left;
background-color: #2A58AE;
margin:0;
height:38px;
min-width:80%;
line-height:38px;
box-shadow: 2px 3px 5px 0 #555;
}
h2 {
margin:0;
}
<div class="cont-title">
<div class="triang-header"></div><div class="h2-stripe"><h2 itemprop="name">
Title
</h2>
</div>
</div>
In the second div, you have line height and lot of other stuff. So other elements can extend your div. If you want your div to be the same size regardless to its other elements you should change display attribute like this
.h2-strispe{
position:relative;
z-index:10;
display:inline-block;
box-sizing:border-box;
text-align:left;
background-color: #2A58AE;
margin:0;
height:38px;
min-width:80%;
line-height:38px;
box-shadow: 2px 3px 5px 0 #555;
}
You can see i added box-sizing to border-box and that will save the position of your div no matter what you do to inner elements

How do I set a partially transparent background on a div?

I want the divs to be partially transparent so that the background can be seen through, but want the other elements <p> not to be transparent as they are in the image. Currently I am using opacity: .4.
HTML
<!-- tarifas starts here-->
![<div class="tarifas">
<h1>Tarifas</h1>
<h3>Consigue la máxima experiencia sin preocuparte por el roaming</h3>
<div class="tarifas_left">
<div class="tarifas_left_top">
<p>5€<span>/día</span></p>
</div>
<div class="tarifas_left_bottom">
<p>hasta<span>1Gb</span>/día</p>
<p>router wifi movil</p><button>
<p>RESERVAR</p></button>
</div>
</div>
<div class="tarifas_right">
<div class="tarifas_right_top">
<p>30€<span>/mes</span></p>
</div>
<div class="tarifas_right_bottom">
<p>hasta<span>7Gb</span>/día</p>
<p>router wifi movil</p><button>
<p>RESERVAR</p></button>
</div>
</div>
</div>
CSS
tarifas {
background:url(image/air_image1.jpg) no-repeat scroll 0 -332px rgba(0,0,0,0);
height:460px;
position:relative;
width:100%
}
.tarifas h1 {
font-size:40px;
color:#fff;
margin-left:500px;
margin-top:28px;
position:absolute;
font-family:HelveticaNeue-Light
}
.tarifas h3 {
font-size:24px;
color:#fff;
margin-left:232px;
margin-top:100px;
position:absolute;
font-family:HelveticaNeue-Light
}
.tarifas_left_top {
position:absolute;
width:285px;
height:80px;
background-color:#AEABA1;
margin-top:150px;
margin-left:290px;
border-radius:10px 10px 0 0;
opacity:.4;
border:2px solid #fff
}
.tarifas_left_bottom {
position:absolute;
width:285px;
height:170px;
background-color:#AEABA1;
margin-top:237px;
margin-left:290px;
border-radius:0 0 10px 10px;
opacity:.4;
border:2px solid #fff
}
.tarifas_left_top p {
font-size:67.48px;
color:#fff;
text-align:center;
font-family:HelveticaNeue-Light;
opacity:1
}
.tarifas_left_top p span {
font-size:12px;
color:#fff;
font-family:HelveticaNeue-Light
}
.tarifas_left_bottom p:nth-child(1) {
font-size:12px;
color:#fff;
text-align:center;
font-family:HelveticaNeue-Light
}
.tarifas_left_bottom p:nth-child(1) span {
font-size:24px;
color:#fff;
font-family:HelveticaNeue-Light
}
.tarifas_left_bottom p:nth-child(2) {
font-size:24px;
color:#fff;
text-align:center;
font-family:HelveticaNeue-Light
}
.tarifas_left_bottom button {
border-radius:10px;
color:#fff;
font-size:20px;
height:39px;
margin-left:65px;
margin-top:55px;
width:155px;
font-family:HelveticaNeue-Light;
opacity:1
}
.tarifas_right_top {
position:absolute;
width:285px;
height:80px;
background-color:#AEABA1;
margin-top:150px;
margin-left:600px;
border-radius:10px 10px 0 0;
opacity:.4;
border:2px solid #fff
}
.tarifas_right_bottom {
position:absolute;
width:285px;
height:170px;
background-color:#AEABA1;
margin-top:237px;
margin-left:600px;
border-radius:0 0 10px 10px;
opacity:.4;
border:2px solid #fff
}
.tarifas_right_top p {
font-size:67.48px;
color:#fff;
text-align:center;
font-family:HelveticaNeue-Light
}
.tarifas_right_top p span {
font-size:12px;
color:#fff;
font-family:HelveticaNeue-Light
}
.tarifas_right_bottom p:nth-child(1) {
font-size:12px;
color:#fff;
text-align:center;
font-family:HelveticaNeue-Light
}
.tarifas_right_bottom p:nth-child(1) span {
font-size:24px;
color:#fff;
font-family:HelveticaNeue-Light
}
.tarifas_right_bottom p:nth-child(2) {
font-size:24px;
color:#fff;
text-align:center;
font-family:HelveticaNeue-Light
}
.tarifas_right_bottom button {
border-radius:10px;
color:#fff;
font-size:20px;
height:39px;
margin-left:65px;
margin-top:55px;
width:155px;
font-family:HelveticaNeue-Light;
opacity:1
}
and the screenshot:
Use rgba colors rather than opacity which affects the children of an element.
So for instance
background-color: #AEABA1
opacity: .4
would translate into:
background-color: rgba(174, 171, 161, 0.4)
You can find a HEX to RGBA convertor here
For the classes .tarifas_left_top and .tarifas_left_bottom, remove the opacity and instead use background-color: rgba(#,#,#,#). For the background color #AEABA1 with opacity 0.4, this translates to background-color: rgba(174,171,161,0.4).
For IE 8 and below, you'll need to override the background with a filter property.
.tarifas_left_top {
background-color: rgba(174,171,161,0.4);
background: transparent\9;
/* This '\9' is intentional. It's a CSS hack, but
it works, and it resets the background in IE 8
and below only. */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#66AEABA1,endColorstr=#66AEABA1);
zoom: 1;
}
Effectively, this gives you cross-browser semi-transparent backgrounds without affecting the opacity of the element's children. These properties can also be used for the border-color and color properties.