Hero image is covering all text and logo? - html

I'm super new to coding, and I can't for the life of me figure out why the hero image covers the other content, even using z-index.
Here is what the web page should look like but the hero image covers the logo, top nav bar, and header/description text about the first castle.
body {
margin: 0;
padding: 0;
}
* {
font-family: 'Open Sans', sans-serif;
}
header,
footer,
main {
width: 1040px;
margin: 0 auto;
}
h1 {
font: 700 30px 'Roboto Slab', serif;
z-index: 1;
position: absolute;
display: inline-block;
}
header p {
font: 18px/1.2 'Open Sans', sans-serif;
}
header ul {
font-size: 15px;
line-height: 1.2;
}
h2 {
font-size: 17px;
font-weight: 700;
line-height: 1.2;
margin: 0;
padding: 0;
}
div p {
margin: 0;
}
main p {
font-size: 13px;
line-height: 1.2;
}
h2,
main div p {
color: #fff;
}
footer ul {
display: inline-block;
margin: 0 auto;
list-style: none;
}
footer li,
header li {
float: left;
padding: 0 20px;
}
footer a {
font-size: 15px;
color: #666;
text-decoration: none;
transition: color .4s;
}
header ul {
display: block;
list-style: none;
}
header a {
color: #fff;
text-decoration: none;
transition: color .4s;
}
footer a:hover {
color: #000;
}
footer a:focus {
color: #000;
}
header a:hover {
color: #000;
}
header a:focus {
color: #000;
}
footer nav {
position: absolute;
top: 760px;
left: 460px;
}
main div:nth-of-type(1) {
display: block;
position: absolute;
left: 126px;
top: 658px;
}
main div:nth-of-type(2) {
display: block;
position: absolute;
left: 472px;
top: 658px;
}
main div:nth-of-type(3) {
display: block;
position: absolute;
left: 817px;
top: 658px;
}
main div {
background-color: rgba(0, 0, 0, 0.4);
padding: 10px 0px 5px 10px;
width: 310px;
}
.img1 {
position: absolute;
top: 0;
right: 110px;
z-index: 1000;
}
.img2 {
display: block;
float: left;
margin: 320px 10px 100px 15px;
}
.twitter {
position: absolute;
display: block;
top: 0px;
right: -335px;
}
.facebook {
position: absolute;
display: block;
top: 0px;
right: -295px;
}
/*.logo {display: block; position: absolute; top: 0; left: 0;
z-index: 2;}*/
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<!-- oxygwen, July 17, 2020 -->
<title>Castle Explorers European Tours</title>
<meta charset="utf-8" />
<meta name="description" content="The home page for Castle Explorers, a tour company that takes travelers to see famous castles in Europe." />
<link rel="stylesheet" type="text/css" href="main.css" />
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght#700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght#400;700&display=swap" rel="stylesheet">
</head>
<body>
<header>
<nav>
<img src="http://via.placeholder.com/300" width="124" height="55" alt="Castle Explorers" />
<ul>
<li>UPCOMING EVENTS</li>
<li>SCHEDULE TOURS</li>
<li>CONTACT</li>
</ul>
</nav>
</header>
<main>
<h1>Moritzburg Castle</h1>
<p>Enjoy the grandeur of this Baroque palace located on a beautiful lake in Germany.</p>
<img class="img1" src="http://via.placeholder.com/300" width="1040" height="400" alt="Moritzburg Castle" />
<img class="img2" src="http://via.placeholder.com/300" width="320" height="300" alt="Mont Saint Michel Abbey" />
<img class="img2" src="http://via.placeholder.com/300" width="320" height="300" alt="Eilean Donan Castle" />
<img class="img2" src="http://via.placeholder.com/300" width="320" height="300" alt="Neuschwanstein Castle" />
<div class="div1">
<h2>Mont Saint-Michel Abbey</h2>
<p>Visit the Normandy coast and this magical castle from the middle ages.</p>
</div>
<div class="div2">
<h2>Eilean Donan Castle</h2>
<p>Explore the 13th century castle of Clan Mackenzie where three sea lochs meet.</p>
</div>
<div class="div3">
<h2>Neuschwanstein Castle</h2>
<p>Be enchanted by the Bavarian castle that was the inspiration for Cinderella's Castle at Disney World.</p>
</div>
</main>
<footer>
<nav>
<ul>
<li>Privacy</li>
<li>Legal Notices</li>
<li>Press</li>
</ul>
<img class="facebook" src="facebook.png" width="17" height="24" alt="facebook link" />
<img class="twitter" src="twitter.png" width="26" height="24" alt="twitter link" />
</nav>
</footer>
</body>
</html>
Specs:
Summary
You are coding the home page for Castle Explorers.
Use any combination of positioning, float, and the box model to create the layout.
This layout could draw from any of the material in the course.
Specifications
Name the HTML5 file index.html
All of the CSS will be in an external file referenced via a link tag; naming this main.css or styles.css is a typical file name for a stylesheet used by an entire website (if we were to build out the site, which will not be happening, all the CSS would go into this one file).
In the head region of the page include a comment with your name and the date.
Provide a good meta description.
The attached screenshots provide the title tag value to use.
This layout is fixed width centered. It is 1040 pixels wide. Disable margin and padding on body (set them to 0).
Two Google Web Fonts are used. 'Moritzburg Castle' uses Roboto Slab and has a weight of 700. All other text uses Open Sans and is either 400 or 700 for weight.
As noted in the summary, your approach to this will involve any combination of positioning, float, and box model.
The graphics are all in the attached zip archive and screenshots are provided for Firefox, Chrome, and Edge.
As you explore the screenshots you may want to use a graphics program such as Paint.NET to determine placement of text, graphics, etc. There is a free version of that software you can download. Mac users could try Pinta. There are also dozens of other options. Some people like to use the Perfect Pixel browser extension to overlay a screenshot over your rendering.
'Moritzburg Castle' is an h1 that is 30px and has font-weight 700. As noted previously, it is the only text using Roboto Slab. The default line-height is fine to use there.
The text below it is 18px Open Sans with 1.2 line-height.
The top navigation is an unordered list. Text size is 15px with 1.2 line-height.
The text for the series of 3 castles (for their names) are h2 that are 17px, 700 font weight, and 1.2 line-height.
The text below those castle name h2's are 13px with 1.2 line-height.
I recommend using rgba(0,0,0,0.4) to create the transparency for the h2's and their additional text. The padding there is 10px on all sides except the right-hand side, which is 5px.
The footer links are also an unordered list, but because they are centered you may want to display those list items as inline-block. There is 40px between them, but keep in mind that inline-block will render a single space if it exists in the code, so eliminating white space between list items is recommended.
The footer links are 15px and their color is #666.
The top navigation and the footer links all change to #000 on hover and focus; give them a CSS transition of: color .4s ease-in
The social media icons don't need to be an unordered list; they can just be a pair of anchors containing the images. There is 15px of space between the icons, but if they are displayed inline-block remember to eliminate white space between those anchors to avoid introducing extra space.
All links will use href="#". The linked elements are:
Logo
Top Navigation
All four castle photos
Footer Navigation
Social media icons
Make sure that image alt attribute values are appropriate and descriptive.
HTML structural elements (header, main, footer, nav) need to be used appropriately.
Any ideas? Getting desperate because it's due in a few hours...thanks!

h1 {
font: 700 30px 'Roboto Slab', serif;
z-index: 1;
position: relative; << Change to this
display: inline-block;
.img1 {
position: absolute; << Remove this
top: 0;
right: 110px;
z-index: 1000;
This happens to you because you are using position: absolute; for your image along with the H1 text which makes the image appear above other elements you just have to remove that image position: absolute; and insert your h1 tag into the image div itself or make it position: relative;
Tell me if this fixes your issue I checked it with chrome dev tools :D

Related

Extra space at the bottom of the container

I am trying to replicate this design http://www.csszengarden.com/217/ for practice purposes.
I've got almost everything right, except that the height of my body is larger than the content it contains.
this is the code
*{
list-style: none;
font-family: 'tablet-gothic-thin', sans-serif;
}*
div {
display: block;
}
html {
padding: 5%;
background-color: #daede2;
}
body {
margin: 0;
padding: 0;
background-color: #77c4d3;
display: block;
}
.page-wrapper {
margin: 0;
padding: 0;
height: auto;
box-sizing: border-box;
position: relative;
z-index: 2;
display: block;
}
.sidebar {
background: rgba(246,247,146,0.9);
position: absolute;
top: 120px;
right: 0px;
width: 30%;
padding: 1%;
z-index: 2;
display: block;
}
.preamble {
background: rgba(255, 255, 255,0.9);
position: relative;
width: 50%;
top: 100px;
left: -70px;
margin: 20px 0;
line-height: 25px;
padding-left: 120px;
padding-top: 40px;
padding-bottom: 40px;
padding-right: 40px;
}
.preamble h3 {
font-size: 40px;
margin-left: 0px;
margin-bottom: 20px;
font-weight: lighter;
}
.preamble p {
margin-top: 0;
padding: 1%;
font-family: sans-serif;
font-size: 17px;
line-height: 25px;
margin: 0.5%;
color: black;
font-weight: lighter;
}
header {
margin: 20px;
}
header h1 {
background-color: #ea2e49;
padding: 15px 15px;
text-align: center;
text-transform: uppercase;
width: 280.05px;
position: relative;
top: 50px;
left: 30px;
font-size: 30px;
font-family: 'tablet-gothic', sans-serif;
font-style: normal;
font-weight: 200;
color: white;
}
header h2 {
font-family: 'Coda Caption', sans-serif;
color: white;
letter-spacing: -7px;
font-size: 110px;
width: 700px;
line-height: 1;
position: relative;
top: 0px;
left: 30px;
}
.summary {
width: 50%;
position: relative;
}
.summary p {
position: relative;
left: 60px;
letter-spacing: 2px;
text-transform: uppercase;
color: white;
font-family: 'tablet-gothic', sans-serif;
font-size: 18px;
}
.summary p:last-child {
border-top: 1px solid #ea2e49;
margin-top: 20px;
padding-top: 25px;
}
.summary p:last-child a {
}
a {
text-decoration: none;
color: white;
border-bottom: 1px solid rgba(0,0,0,0.2);
transition: border-color 0.2s ease-in-out;
}
a:hover {
border-bottom: 1px solid #ea2e49;
}
.select {
font-size: 40px;
font-weight: lighter;
margin-top: 50px;
margin-left: 33px;
margin-bottom: 10px;
text-align: inherit;
}
.design-selection ul {
text-align: inherit;
margin-top: 5px;
margin-left: -5px;
padding-right: 30px;
}
.design-selection li {
font-size: 17px;
line-height: 35px;
color: rgba(0,0,0,0.2);
}
.design-selection li a {
color: black;
}
.archives {
font-size: 40px;
font-weight: lighter;
margin-top: 80px;
margin-left: 33px;
margin-bottom: 10px;
text-align: inherit;
}
.design-archives ul {
text-align: inherit;
margin-top: 5px;
margin-left: -5px;
padding-right: 30px;
}
.design-archives li {
font-size: 17px;
line-height: 35px;
color: rgba(0,0,0,0.2);
}
.design-archives li a {
color: black;
}
.resources {
font-size: 40px;
font-weight: lighter;
margin-top: 80px;
margin-left: 33px;
margin-bottom: 10px;
text-align: inherit;
}
.zen-resources ul {
text-align: inherit;
margin-top: 5px;
margin-left: -5px;
padding-right: 30px;
margin-bottom: 50px;
}
.zen-resources li {
font-size: 17px;
line-height: 35px;
color: rgba(0,0,0,0.2);
}
.zen-resources li a {
color: black;
}
.extra1 {
position: fixed;
z-index: 1;
width: 30%;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(51,55,69,0.9);
}
.main-supporting {
display: block;
position: relative;
padding: 1%;
}
.explanation {
display: block;
position: relative;
top: 253px;
left: 80px;
width: 39%;
padding: 1%;
}
.explanation h3 {
font-family: sans-serif;
font-weight: lighter;
color: white;
margin-left: 5px;
font-size: 30px;
}
.explanation p {
padding: 1%;
font-family: sans-serif;
font-size: 17px;
line-height: 25px;
margin: 0.5%;
color: white;
font-weight: lighter;
}
.participation {
display: block;
position: relative;
top: -265px;
left: 600px;
width: 35%;
padding: 5%;
background: rgba(234,46,73,0.9);
z-index: 3;
}
.participation p {
margin-top: 0;
padding: 1%;
color: white;
line-height: 25px;
font-family: sans-serif;
font-size: 17px;
}
.participation a:hover {
border-bottom: 1px solid white;
}
.participation h3 {
font-family: sans-serif;
font-size: 30px;
color: white;
margin left: 20px;
margin-bottom: 10px;
font-weight: lighter;
}
.benefits {
display: block;
position: relative;
width: 15%;
background: rgba(255,255,255,0.9);
padding: 5%;
top: -150px;
left: 78px;
}
.benefits p {
font-family: sans-serif;
line-height: 25px;
font-weight: lighter;
font-size: 17px;
}
.benefits h3 {
font-family: sans-serif;
font-size: 25px;
font-weight: lighter;
}
.requirements {
display: block;
background: rgba(255,255,255,0.9);
width: 59%;
position: relative;
top: -833px;
left: 381px;
padding: 2%;
}
.requirements p {
font-family: sans-serif;
line-height: 25px;
font-size: 17px;
}
.requirements p:first-child {
margin: 50px 50px 20px 50px;
}
.requirements p:nth-child(2) {
margin: 0px 50px 20px 50px;
}
.requirements p:nth-child(3) {
margin: 0px 50px 20px 50px;
}
.requirements p:nth-child(4) {
margin: 0px 50px 20px 50px;
}
.requirements p:nth-child(5) {
margin: 0px 50px 20px 50px;
padding-bottom: 3%;
}
.requirements p:nth-child(6) {
margin: 0px 50px 40px 50px;
padding-top: 5%;
border-top: 1px solid #ea2e49;
text-transform: uppercase;
}
.requirements h3 {
margin: 50px 50px 10px 50px;
font-family: sans-serif;
font-size: 25px;
font-weight: lighter;
}
.requirements a {
color: black;
}
footer {
position: relative;
display: block;
top: -834.5px;
left: 60px;
background: rgba(246,247,146,0.9);
width: 45%;
padding: 1.5%;
margin-bottom: 0px;
}
footer a {
color: black;
margin-left: 3%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Zen Garden: The Beauty of CSS Design</title>
<link rel="stylesheet" media="screen" href="style.css?v=8may2013">
<link rel="stylesheet" type="text/css" href="design.css">
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.csszengarden.com/zengarden.xml">
<link href="https://fonts.googleapis.com/css?family=Coda+Caption:800" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Dave Shea">
<meta name="description" content="A demonstration of what can be accomplished visually through CSS-based design.">
<meta name="robots" content="all">
<!--[if lt IE 9]>
<script src="script/html5shiv.js"></script>
<![endif]-->
</head>
<!--
View source is a feature, not a bug. Thanks for your curiosity and
interest in participating!
Here are the submission guidelines for the new and improved csszengarden.com:
- CSS3? Of course! Prefix for ALL browsers where necessary.
- go responsive; test your layout at multiple screen sizes.
- your browser testing baseline: IE9+, recent Chrome/Firefox/Safari, and iOS/Android
- Graceful degradation is acceptable, and in fact highly encouraged.
- use classes for styling. Don't use ids.
- web fonts are cool, just make sure you have a license to share the files. Hosted
services that are applied via the CSS file (ie. Google Fonts) will work fine, but
most that require custom HTML won't. TypeKit is supported, see the readme on this
page for usage instructions: https://github.com/mezzoblue/csszengarden.com/
And a few tips on building your CSS file:
- use :first-child, :last-child and :nth-child to get at non-classed elements
- use ::before and ::after to create pseudo-elements for extra styling
- use multiple background images to apply as many as you need to any element
- use the Kellum Method for image replacement, if still needed.
- don't rely on the extra divs at the bottom. Use ::before and ::after instead.
-->
<body id="css-zen-garden">
<div class="page-wrapper">
<section class="intro" id="zen-intro">
<header role="banner">
<h1>CSS Zen Garden</h1>
<h2>The Beauty of <abbr title="Cascading Style Sheets">CSS</abbr> Design</h2>
</header>
<div class="summary" id="zen-summary" role="article">
<p>A demonstration of what can be accomplished through <abbr title="Cascading Style Sheets">CSS</abbr>-based design. Select any style sheet from the list to load it into this page.</p>
<p>Download the example html file and css file</p>
</div>
<div class="preamble" id="zen-preamble" role="article">
<h3>The Road to Enlightenment</h3>
<p>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible <abbr title="Document Object Model">DOM</abbr>s, broken <abbr title="Cascading Style Sheets">CSS</abbr> support, and abandoned browsers.</p>
<p>We must clear the mind of the past. Web enlightenment has been achieved thanks to the tireless efforts of folk like the <abbr title="World Wide Web Consortium">W3C</abbr>, <abbr title="Web Standards Project">WaSP</abbr>, and the major browser creators.</p>
<p>The CSS Zen Garden invites you to relax and meditate on the important lessons of the masters. Begin to see with clarity. Learn to use the time-honored techniques in new and invigorating fashion. Become one with the web.</p>
</div>
</section>
<div class="main supporting" id="zen-supporting" role="main">
<div class="explanation" id="zen-explanation" role="article">
<h3>So What is This About?</h3>
<p>There is a continuing need to show the power of <abbr title="Cascading Style Sheets">CSS</abbr>. The Zen Garden aims to excite, inspire, and encourage participation. To begin, view some of the existing designs in the list. Clicking on any one will load the style sheet into this very page. The <abbr title="HyperText Markup Language">HTML</abbr> remains the same, the only thing that has changed is the external <abbr title="Cascading Style Sheets">CSS</abbr> file. Yes, really.</p>
<p><abbr title="Cascading Style Sheets">CSS</abbr> allows complete and total control over the style of a hypertext document. The only way this can be illustrated in a way that gets people excited is by demonstrating what it can truly be, once the reins are placed in the hands of those able to create beauty from structure. Designers and coders alike have contributed to the beauty of the web; we can always push it further.</p>
</div>
<div class="participation" id="zen-participation" role="article">
<h3>Participation</h3>
<p>Strong visual design has always been our focus. You are modifying this page, so strong <abbr title="Cascading Style Sheets">CSS</abbr> skills are necessary too, but the example files are commented well enough that even <abbr title="Cascading Style Sheets">CSS</abbr> novices can use them as starting points. Please see the <abbr title="Cascading Style Sheets">CSS</abbr> Resource Guide for advanced tutorials and tips on working with <abbr title="Cascading Style Sheets">CSS</abbr>.</p>
<p>You may modify the style sheet in any way you wish, but not the <abbr title="HyperText Markup Language">HTML</abbr>. This may seem daunting at first if you’ve never worked this way before, but follow the listed links to learn more, and use the sample files as a guide.</p>
<p>Download the sample HTML and CSS to work on a copy locally. Once you have completed your masterpiece (and please, don’t submit half-finished work) upload your <abbr title="Cascading Style Sheets">CSS</abbr> file to a web server under your control. Send us a link to an archive of that file and all associated assets, and if we choose to use it we will download it and place it on our server.</p>
</div>
<div class="benefits" id="zen-benefits" role="article">
<h3>Benefits</h3>
<p>Why participate? For recognition, inspiration, and a resource we can all refer to showing people how amazing <abbr title="Cascading Style Sheets">CSS</abbr> really can be. This site serves as equal parts inspiration for those working on the web today, learning tool for those who will be tomorrow, and gallery of future techniques we can all look forward to.</p>
</div>
<div class="requirements" id="zen-requirements" role="article">
<h3>Requirements</h3>
<p>Where possible, we would like to see mostly <abbr title="Cascading Style Sheets, levels 1 and 2">CSS 1 & 2</abbr> usage. <abbr title="Cascading Style Sheets, levels 3 and 4">CSS 3 & 4</abbr> should be limited to widely-supported elements only, or strong fallbacks should be provided. The CSS Zen Garden is about functional, practical <abbr title="Cascading Style Sheets">CSS</abbr> and not the latest bleeding-edge tricks viewable by 2% of the browsing public. The only real requirement we have is that your <abbr title="Cascading Style Sheets">CSS</abbr> validates.</p>
<p>Luckily, designing this way shows how well various browsers have implemented <abbr title="Cascading Style Sheets">CSS</abbr> by now. When sticking to the guidelines you should see fairly consistent results across most modern browsers. Due to the sheer number of user agents on the web these days — especially when you factor in mobile — pixel-perfect layouts may not be possible across every platform. That’s okay, but do test in as many as you can. Your design should work in at least IE9+ and the latest Chrome, Firefox, iOS and Android browsers (run by over 90% of the population).</p>
<p>We ask that you submit original artwork. Please respect copyright laws. Please keep objectionable material to a minimum, and try to incorporate unique and interesting visual themes to your work. We’re well past the point of needing another garden-related design.</p>
<p>This is a learning exercise as well as a demonstration. You retain full copyright on your graphics (with limited exceptions, see submission guidelines), but we ask you release your <abbr title="Cascading Style Sheets">CSS</abbr> under a Creative Commons license identical to the one on this site so that others may learn from your work.</p>
<p role="contentinfo">By Dave Shea. Bandwidth graciously donated by mediatemple. Now available: Zen Garden, the book.</p>
</div>
<footer>
HTML
CSS
CC
A11y
GH
</footer>
</div>
<aside class="sidebar" role="complementary">
<div class="wrapper">
<div class="design-selection" id="design-selection">
<h3 class="select">Select a Design:</h3>
<nav role="navigation">
<ul>
<li>
Mid Century Modern by Andrew Lohman
</li> <li>
Garments by Dan Mall
</li> <li>
Steel by Steffen Knoeller
</li> <li>
Apothecary by Trent Walton
</li> <li>
Screen Filler by Elliot Jay Stocks
</li> <li>
Fountain Kiss by Jeremy Carlson
</li> <li>
A Robot Named Jimmy by meltmedia
</li> <li>
Verde Moderna by Dave Shea
</li> </ul>
</nav>
</div>
<div class="design-archives" id="design-archives">
<h3 class="archives">Archives:</h3>
<nav role="navigation">
<ul>
<li class="next">
<a href="/214/page1">
Next Designs <span class="indicator">›</span>
</a>
</li>
<li class="viewall">
<a href="http://www.mezzoblue.com/zengarden/alldesigns/" title="View every submission to the Zen Garden.">
View All Designs </a>
</li>
</ul>
</nav>
</div>
<div class="zen-resources" id="zen-resources">
<h3 class="resources">Resources:</h3>
<ul>
<li class="view-css">
<a href="style.css" title="View the source CSS file of the currently-viewed design.">
View This Design’s <abbr title="Cascading Style Sheets">CSS</abbr> </a>
</li>
<li class="css-resources">
<a href="http://www.mezzoblue.com/zengarden/resources/" title="Links to great sites with information on using CSS.">
<abbr title="Cascading Style Sheets">CSS</abbr> Resources </a>
</li>
<li class="zen-faq">
<a href="http://www.mezzoblue.com/zengarden/faq/" title="A list of Frequently Asked Questions about the Zen Garden.">
<abbr title="Frequently Asked Questions">FAQ</abbr> </a>
</li>
<li class="zen-submit">
<a href="http://www.mezzoblue.com/zengarden/submit/" title="Send in your own CSS file.">
Submit a Design </a>
</li>
<li class="zen-translations">
<a href="http://www.mezzoblue.com/zengarden/translations/" title="View translated versions of this page.">
Translations </a>
</li>
</ul>
</div>
</div>
</aside>
</div>
<!--
These superfluous divs/spans were originally provided as catch-alls to add extra imagery.
These days we have full ::before and ::after support, favour using those instead.
These only remain for historical design compatibility. They might go away one day.
-->
<div class="extra1" role="presentation"></div><div class="extra2" role="presentation"></div><div class="extra3" role="presentation"></div>
<div class="extra4" role="presentation"></div><div class="extra5" role="presentation"></div><div class="extra6" role="presentation"></div>
</body>
</html>
As you can see in the code snippet, there is extra space after the contents.
I need help with this.
Thank You.
There are postives and negatives when using relative position in this layout..
Look at the shot below
your div with id zen-requirements has been relative positioned in the layout and there is top: -833px;. take out this top and you will notice that the initial position of the div takes up that space you are trying to get rid of (not forgetting a little bit of padding somewhere).....
hmmmm....Sticking to this layout..I believe you will have to adjust the size of your div that has class page-wrapper (add an id to avoid other classes being affected)
Add these rules to id..
height: 3000px;
overflow:hidden
A Javascript approach to find computed position of last yellow footer relative to window top and auto adjust the window size might work...
I think it's because of the relative positioning of .requirements block.
See: position:relative leaves an empty space
If you add a fixed size to your container, it can fix the issue, but in general your design is different from the sample you shown. Try this:
#zen-supporting {
height: 1750px;
}
html{ padding: 5%} is the reason. It makes extra space in the bottom too.
You can set it as: html{padding: 5% 5% 0 5%}
Edit
If you, also, mean the extra space in blue color under the navigation contains, HTML, CSS, ... you may also adjust the padding of div.main:
div.main {
padding: 5% 5% 0 5%;
}
to be like the following screen shot:

Floating to the right

I am designing a website using HTML and CSS and there appears to be an invisible margin somewhere.
Currently, my website looks like this:
h1, h2 {
font-family: 'Righteous', cursive;
text-align: center;
}
body {
font-family: 'Roboto', sans-serif;
color: black;
border: 5px solid #375E97;
}
article, aside {
padding: 1%;
margin: 1.5% 0;
border: 5px solid #375E97;
border-left: 0;
display: inline-block;
vertical-align: top;
}
article {
width: 60%;
}
aside {
width: 30%;
background-image: url("money-stack.png");
background-size: cover;
background-position: 200px 200px;
}
h1 {
background-color: #375E97;
color: #FFFFFF;
font-size: 6.9vw;
text-transform: uppercase;
padding: 0;
margin: 0 auto 2.1% auto;
line-height: 4.9vw;
height: 5vw;
}
h2 {
color: #375E97;
font-size: 3.5vw;
padding: 0;
margin: 0;
}
p {
padding: 0;
margin: 1% 0 0 0;
font-size: 1vw;
}
.sub-heading {
font-style: italic;
text-align: center;
}
.sub-heading > span {
font-weight: 700;
font-style: normal;
}
<!DOCTYPE html>
<html>
<head>
<title>Act 1</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Righteous|Roboto:400,700,400i" rel="stylesheet">
</head>
<body>
<header>
<h1>Filler text here</h1>
</header>
<article>
<h2>More more</h2>
<p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.</p>
<p>Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.</p>
<p>A small river named Duden flows by their place and supplies it with the necessary regelialia.</p>
<p>It is a paradisematic country, in which roasted parts of sentences fly into your mouth.</p>
<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p>
</article>
<aside>
<h2>And More</h2>
<p>
<div class="sub-heading">
<p>She packed her seven versalia, put her initial into the belt and made herself on the way.</p>
</div>
<br>
<p>The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen.</p>
</p>
</aside>
</body>
</html>
If you look closely at the article and aside in the middle of the screenshot, you can see that I have made their display: inline-block; and removed the border from the left of the aside (smaller one).
The Problem
The problem is that I want to actually "pin" the aside to the right of the body, not the article. I know that to make this work I would have to remove the border from the right and add it to the left.
What I Have Tried
Playing around with various values for align, text-align and all the other aligns you can think of.
Making the aside and article have no tags in between them.
Please note, I have seen other solutions for this, but I want a clean solution that makes sense.
This is what you were trying to achieve I guess.
article and aside are now floated left and right.
This is actually the solution from kukkuz in the comments. I don't know why it shouldn't work for you.
A clearfix is used instead of an additional element with clear: both
Without the surrounding element, body in this case, doesn't get the height from its content and the border around everything wouldn't display correctly.
h1, h2 {
font-family: 'Righteous', cursive;
text-align: center;
}
body {
font-family: 'Roboto', sans-serif;
color: black;
border: 5px solid #375E97;
}
body:after {
content: '';
clear: both;
display: table;
}
article, aside {
padding: 1%;
margin: 1.5% 0;
border: 5px solid #375E97;
border-left: 0;
}
article {
width: 60%;
float: left;
}
aside {
width: 30%;
border-left: 5px solid #375E97;
border-right: 0;
float: right;
background-image: url("money-stack.png");
background-size: cover;
background-position: 200px 200px;
}
h1 {
background-color: #375E97;
color: #FFFFFF;
font-size: 6.9vw;
text-transform: uppercase;
padding: 0;
margin: 0 auto 2.1% auto;
line-height: 4.9vw;
height: 5vw;
}
h2 {
color: #375E97;
font-size: 3.5vw;
padding: 0;
margin: 0;
}
p {
padding: 0;
margin: 1% 0 0 0;
font-size: 1vw;
}
.sub-heading {
font-style: italic;
text-align: center;
}
.sub-heading > span {
font-weight: 700;
font-style: normal;
}
<!DOCTYPE html>
<html>
<head>
<title>Act 1</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Righteous|Roboto:400,700,400i" rel="stylesheet">
</head>
<body>
<header>
<h1>Filler text here</h1>
</header>
<article>
<h2>More more</h2>
<p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.</p>
<p>Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.</p>
<p>A small river named Duden flows by their place and supplies it with the necessary regelialia.</p>
<p>It is a paradisematic country, in which roasted parts of sentences fly into your mouth.</p>
<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p>
</article>
<aside>
<h2>And More</h2>
<p>
<div class="sub-heading">
<p>She packed her seven versalia, put her initial into the belt and made herself on the way.</p>
</div>
<br>
<p>The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen.</p>
</p>
</aside>
</body>
</html>
I hope I understood your issue. There's many ways you could achieve this, the most obvious one would be to remove your inline rule and make both aside and article float: right; and float: left; respectively, but float was intended to make text float around images and not exactly to position divs (eventhough it works). As so, what I would try is to position: absolute; both the aside and article; and use left, right, top, bottom to position elements.
article {
position: absolute;
top: 69px;
width: 60%;
}
aside {
background-image: url("money-stack.png");
background-position: 200px 200px;
background-size: cover;
position: absolute;
right: 8px;
top: 69px;
width: 30%;
}
body {
border: 5px solid #375e97;
color: black;
font-family: "Roboto",sans-serif;
min-height: 318px;
}
After, you can either set a minimum size for the container, or add a clear:both; styled element to the bottom in order to make the container stretch to the correct size.
One other thing I think you should change is the fact that you're using body as your container and applying styles to it. I think it's good practice to create an actual container div, and apply styles to that instead.

<A Href> has a lot of empty space beneath the text

EDIT: I've made a few changes, based on suggestions, but the problem is persisting on IE, and I don't think I'm doing anything too fancy for IE. I'm not sure what's getting lost in translation.
I'm working on an assignment for class, where we're using html & css to make a web page.
I'm trying to create a horizontal nav bar at the top of a web page, and I've gotten the navbar to behave mostly how I'd like. The problem is that I want the text of the link snug against the bottom of the nav bar, but the area of the link is doing one of two things depending on how I approached the problem (EDIT: Now only happening in internet explorer).
My first instinct was to use vertical-align, but I have since read in 5 or 6 threads that it does not work on inline elements.
I have toyed around with altering the height and line height, to try and get an alignment that works (text at the bottom of the link), but that has ended up pushing the text, AND the area of the of the link down past the nav bar.
I've also tried toying with the padding-bottom, to try and see if I can adjust that, and one way or another, and I've only been able to push the link further upward with that.
I've been researching around for something that can help me find a fix, and I've found a lot of articles that are close but no cigar.
Some of the things I've looked at are (woops I guess I can only post two links):
Why anchor tag does not take height and width of its containing element
There was one about empty space beneath certain fonts, and there were several about tables, and several about vertical alignment.
This is where I'm at so far: http://jsfiddle.net/brezzen/w09q7h7y/2/
html:
<body>
<header>
<nav class="header">
<ul>
<li>Contact</li>
<li>Values</li>
<li>About</li>
<li>Home</li>
</ul>
</nav>
</header>
<article>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /> bleep blorp bloop
</article>
</body>
css:
/* Debugging */
*
{
border: 1px solid red;
} */
/* Blocking & Defaults */
header, article, aside, figure, figcaption, hgroup, section, nav
{
display: block;
}
*
{
font-family: 'Kozuka Gothic Pro EL', 'Kozuka Gothic Pro', Myriad, Helvetica, sans-serif;
font-size: 100%;
color: white;
padding: 0px;
margin: 0px;
}
/* Body */
body {
background-color: #bbffff;
font-weight: normal;
position: relative;
min-width: 1000px;
max-width: 2000px;
}
/* All Navigation */
nav {
position: absolute;
right: 0;
top: 0;
width: 100%;
height: 82px;
background-color: #7396ff;
border-bottom: 3px solid #bbbbbb;
}
nav ul {
position: absolute;
bottom: 0;
right: 0;
left: 0;
padding-right: 10%;
list-style-type: none;
font-size: 125%;
}
nav ul li {
display: inline-block;
vertical-align: bottom;
float: right;
}
nav ul li a {
color: white;
text-decoration: none;
}
I don't know what's goin on, but the empty space hanging under the text is huge, so it's hard for me to believe that it's just a font quirk. I thought that moving text around inside of the area of the link would be a lot easier than this, and I think I've gotten in over my head here. Any help, or direction toward a good resource would be greatly appreciated.
line-height You are increasing the font-size to 125% and there is a "height" of each line of text that affects this. (http://jsfiddle.net/w09q7h7y/3/)
nav ul {
position: absolute;
bottom: 0;
right: 0;
left: 0;
padding-right: 10%;
list-style-type: none;
font-size: 125%;
line-height: 1;
}
There are several ways to align an element vertically. If it is only one line of text within an element, the easiest way is to set the line-height the same with the height of the element.
It is not a good practice to use % to set the font-size. Instead, use px, em, or rem.
nav ul {
height: 1.5rem;
}
nav li {
margin: 0;
padding: 0 0.4rem;
height: 1.5rem;
line-height: 1.5rem;
font-size: 1rem;
}
Depending on how you organize your CSS, you might want to add styles to the anchor like this
nav li a {
margin: 0;
padding: 0 0.4rem;
height: 1.5rem;
line-height: 1.5rem;
font-size: 1rem;
}
as well. Pay attention to specificities.

Why won't my hyperlinks change color?

I'm an elderly college student (no kidding!) taking HTML2 now and I figure I've probably missed or mis-coded something in my CSS. But for the life of me, I can't figure out the issue after many attempts/re-try's at locating where the problem lies.
Here's what's wrong...
Hyperlinks normally use "link" in CSS (as in, an untouched link on the page in blue color), "hover" (for when the mouse is over it, call it white color), and "visited" (for after the link has been clicked on, call it purple color). I have 5 pages to link to in my Nav bar. All the links take you to the proper pages, but aren't visually reacting to the mouse or hover AND none of the 5 links are changing color AFTER being visited.
As stated, I've tried many different things but nothing has changed.
Any and all suggestions are greatly appreciated. And keep up the good work that you guys do when helping someone else out of their problem.
PS: This is a HW assignment which I have to validate via http://validator.w3.org/ (and the CSS as well) so solutions have to follow the acceptable guidelines of W3.
Here's my entire CSS (just in case I've written something conflicting in it that could be the issue):
/* Body config */
body { background-color: #000000;
background-image: url(images/Sunset1.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
padding-top: 10px;
font-family: Verdana, Arial, sans-serif;}
/* Heading 1 Style */
h1 { background-position: right;
background-repeat: no-repeat;
padding-left: 20px;
height: 14px;
color: #754719;
font-family: Georgia, serif;
line-height: 120%;}
/* Heading 2 Style for Content heading */
h2 { color: #663311;
font-family: Georgia, serif;}
/* Heading 3 Style */
h3 { color: #000033;}
/* Heading 4 Style */
h4 { color: #ffff00;}
/* Definition List */
dl { margin-left: 340px;}
/* Definition Term */
dt { color: #000033;}
/* Config nav */
#nav { height: 45px;
font-family: Verdana;
font-size: 25px;
line-height: 42px;
background: #DCCAA6;
word-spacing: 2em;
padding-left: 30px;
margin-left: auto; /* Shouldn't these margin-auto lines take care of */
margin-right: auto; /* centering the NavBar without using text-align:center? */
text-align:center;} /* I tried it without text-align but it wouldn't center it */
/* All 3 "nav" lines below (commented out), didn't work. It was recommended at: http://csswizardry.com/2011/01/create-a-centred-horizontal-navigation/ */
/*.nav{
border:5px solid #ccc;
border-width:1px 0;
list-style:none;
margin:0;
padding:0;
text-align:center;
}
.nav li{
display:inline;
}
.nav a{
display:inline-block;
padding:10px;
}*/
/* Config nav hyperlinks */
#nav a { text-decoration: none;}
/* Config nav hyperlinks Pseudo-class */
#nav a:link { color: #e60000;}
#nav a:hover { color: #FFFFFF;}
#nav a:visited { color: #663300;}
/* Config nav unordered list */
#nav ul { list-style-type: none;
margin: 0;
padding-left: 0;}
/* Banner config */
img.displayed { display: block;
margin-left: auto;
margin-right: auto;}
/* Bold Resort Name for span*/
.resort { color: #000033;
font-size: 1.2em;}
/* Config content */
#content { background-color: #ffffff;
margin-top: 0;
margin-right: 20px;
margin-bottom: 5px;
margin-left: 20px;
padding-top: 0;
padding-right: 20px;
padding-bottom: 0;
padding-left: 20px;}
/* Config images */
#content img, #content video, #content embed { float: left;
padding-right: 20px;}
/* Gallery config */
#gallery { position: relative;}
#gallery ul { list-style-type: none;
width: 300px;}
#gallery li { display: inline;
float: left;
padding: 10px;}
#gallery img { border-style: none;
float: none;}
#gallery a { text-decoration: none;
font-style: italic;
color: #333;}
#gallery span { display: none;}
#gallery a:hover span { display: block;
position: absolute;
top: 10px;
left: 340px;
text-align: center;}
/* Clear float */
.clear { clear: left;
text-align: center;
color: #3D1F00;
background-color: #ffffff;
font-family: Comic Sans MS, cursive, sans-serif;}
/* Config unordered lists */
#content ul { list-style-position: inside;}
/* Footer */
#footer { font-size: .70em;
font-style: italic;
text-align: center;
padding: 10px;
clear: both;}
/* Config for page wrapper */
#wrapper { background-color: #E6532E;
opacity: 0.8;
filter: alpha(opacity=80); /* For IE8 and earlier */
min-width: 960px;
-webkit-box-shadow: 5px 5px 5px #828282;
-moz-box-shadow: 5px 5px 5px #828282;
box-shadow: 10px 10px 40px #995c00;
width: 75%;
margin-left: auto;
margin-right: auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#1e1e1e')";}
/* Config table */
table { border: 1px solid #3399cc;
border-spacing: 0;
margin: auto;
width: 600px;}
td, th { border: 1px solid #3399cc;
padding: 5px;}
/* Config table content */
td { text-align: center;}
/* Config class */
.text { text-align: left;}
/* Config alternate row color (pseudo-class) */
tr:nth-of-type(even) { background-color: #f5fafc;}
/* Form controls */
label { float: left;
display: block;
text-align: right;
width: 120px;
padding-right: 20px;}
/* Form input */
input, textarea { display: block;
margin-bottom: 20px;}
/* Submit button */
#mySubmit { margin-left: 130px;}
form { padding-bottom: 30px;}
Update:
It makes all the sense in the world to include the HTML. Sorry, I just wasn't sure what or how much info I could include since my original posting was HERE in StackOverflow but it kept throwing error messages so I rerouted it to WebMasters. Thanks again for any help you guys can offer. I'm pasting the HTML below the CSS. And I did correct the error someone noticed in the order for link,visited, and hover.
<!DOCTYPE html>
<!-- CIS233DA - Section# 11491 -->
<html lang="en">
<head>
<title>Sand and Surf : Home</title>
<meta name="viewport" content="width=device-width">
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<meta name="description" content="Sand and Surf Island Vacations, have Award-winning accommodations specializing in romantic getaways, fun-filled honeymoons, memorable anniversaries, and the most unique vacation of a lifetime.">
<meta name="keywords" content="Award winning resort, unique, romantic, getaways, beaches, sunsets, star filled skies, secluded, couples, relaxing, fun-filled, vacation, honeymoon, anniversary, world wide, savings">
<!-- CSS connection to all pages that include this line -->
<link href="sand.css" rel="stylesheet" type="text/css">
<!-- Begin Site Logo/Banner -->
<img class="displayed" src="images/SSLogoBanner.gif" alt="Sand & Surf Logo Banner"/>
</head>
<!-- "Footprints in sand w bright light" (part of Logo/Banner) used without permission from - http://ditchthesad.com/blog/ By: Jen Herlevi -->
<!-- End Site Logo/Banner -->
<body>
<!-- Begin Wrapper -->
<div id="wrapper">
<!-- Begin Nav Bar -->
<div id="nav">
Home
Destinations
Vacation_Packages
Contact_Us
Design
</div>
<!-- End Nav Bar -->
<!-- Begin content -->
<div id="content">
<!-- Media Controls -->
<video controls="controls" poster="snorkeling_poster.jpg" width="420" height="340">
<source src="Snorkeling.mp4" type="video/mp4">
<embed type="application/x-shockwave-flash" src="Snorkeling.mp4" quality="high" width="320" height="240" title="Sand and Surf Island Vacations">
</video>
<!-- END Media Controls -->
<br>
<br>
<p><span class="resort">Sand and Surf Island Vacations</span> offers a special lodging experience on the California North Coast. Relax in serenity with panoramic views of the Pacific Ocean.</p>
<ul>
<li>Private yurts with decks overlooking the ocean</li>
<li>Activities lodge with fireplace and gift shop</li>
<li>Nightly fine dining at the Overlook Cafe</li>
<li>Heated outdoor pool and whirlpool</li>
<li>Guided hiking tours of the redwoods</li>
</ul>
<div class="clear"><hr>
<p>Sand and Surf, 12345 N. Sand and Surf Blvd., San Diego, CA. 95555<br>800.555.1234</p>
</div><hr>
<!-- Begin footer -->
<div id="footer">Copyright © 2014 Sand and Surf Island Vacations, L.L.C. All rights reserved<br>
Contact Webmaster
</div>
<!-- End footer -->
<!-- Icon for CSS Validation -->
<p>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!"></a>
</p>
<!-- Icon for W3/Badge Builder Validation -->
<img src="http://www.w3.org/html/logo/badge/html5-badge-h-css3.png" width="133" height="64" alt="HTML5 Powered with CSS3 / Styling" title="HTML5 Powered with CSS3 / Styling">
</div>
<!-- End Content -->
</div>
<!-- End Wrapper -->
</body>
</html>
It would help if you included the HTML as well, that way we can see if css is targeting the correct links, etc.
I would say though first try holding ctrl-F5, this will force a browser refresh which will cause it to reload your css encase it using a older css that may not have any revisions you've made.
Next make sure the css is included correctly in the link tag in the header.
Next make sure the css is targeting the correct id,class etc.., just test this by changing the color or something just to make sure.
Definitly include the html though since that would help a a lot in identifying the problem
I took a quick look at your CSS. There is no specification for changing link hover colors except for within a div or something where id= is either nav or gallery. I tested your nav specs and it works for me. For links in general, you will need an a:hover without .nav or #nav which would require a div or something with an id= or class=.
Was that clear? Just create an a:hover without a class or id for links in general.
I should add that some browsers help with this stuff. Chrome for example, has it's developer tools which is what I used to test your CSS and use all the time. If you do not have Chrome installed, I would suggest it unless your browser has this feature.

CSS appears different on Windows than Mac

When I view the site in Windows then most of the site, like the top text, right contact details, nav text and welcome text appear lower than they do on the mac. Mac browsers show the CSS as it should be. Please help me out...
Mac screenshot
Windows screenshot
HTML
<body>
<div id="wholepage">
<header>
<div id="nav_top">
<nav>
<h1 class="slogan">Steel & Fabrication Specialists</h1>
</nav>
</div>
<img class="kks_logo" src="KKSLogo.png" border="0" alt="KKS Services Ltd logo">
<h1 class="logo">KKS</h1>
<h2 class="logosub">Services Ltd</h2>
<h3 class="head_contact">0113 2826946</h3>
<h3 class="head_contact">enquiries#kksservices.co.uk</h3>
<nav id="main_nav">
<ul id="nav_main">
<li><a class="current_index" href="index.html">HOME</a></li>
<li><a class="domestic" href="domestic.html">DOMESTIC</a></li>
<li><a class="automation" href="automation.html">AUTOMATION</a></li>
<li><a class="commercial" href="commercial.html">COMMERCIAL</a></li>
<li><a class="contact" href="contact.html">CONTACT</a></li>
</ul>
</nav>
<img class="rivot" src="rivot.png" alt="KKS Services Ltd Rivot"/>
<img class="rivot2" src="rivot.png" alt="KKS Services Ltd Rivot"/>
<img class="rivot3" src="rivot.png" alt="KKS Services Ltd Rivot"/>
<img class="rivot4" src="rivot.png" alt="KKS Services Ltd Rivot"/>
</header>
<section>
<article>
<img class="railings" src="index_rail.png" alt="KKS Services Gates and Railings"/>
<div id="welcome">
<h1 class="welcome">Welcome</h1>
CSS
.slogan{
position: relative;
width: 960px;
margin-left: auto;
margin-right: auto;
left: 10px;
top: -5px;
color: white;
font-size: 1.3em;
font-family: 'Aldrich', cursive;
}
.kks_logo{
position: relative;
top: 50px;
}
.head_contact{
font-family: 'Aldrich', sans-serif;
position: relative;
left: 10px;
top: -175px;
font-size: 1.5em;
text-align: right;
}
ul#nav_main li{
display: inline;
padding: 26px;
}
ul#nav_main li a{
text-decoration: none;
color: white;
font-family: 'Aldrich', sans-serif;
font-size: 1.4em;
position: relative;
top: 13px;
}
#welcome{
position: relative;
top: -267px;
left: 70px;
width: 840px;
height: 35px;
background-color: rgba(0,0,0,0.6);
border-radius: 5px;
}
#welcome h1{
color: white;
font-family: 'Aldrich', sans-serif;
padding: 10px;
font-size: 200%;
position: relative;
top: -5px;
left: 10px;
}
Thank You!
The problem is the different default styles that browsers have. Neither way of displaying your page is wrong, they are just different.
You have compensated for the default styles of one browser, which makes it look quite different in all other browsers. As long as you compensate for the default styles instead of overriding them, you will have that problem.
For example, for the .slogan style you should set the top and bottom margin to zero, instead of using relative positioning to compensate for the default margin. You can use line-height to center the text vertically in the element, instead of moving it up or down to place it in the center.
Example:
.slogan{
width: 960px;
line-height: 30px;
margin: 0 auto;
color: white;
font-size: 1.3em;
font-family: 'Aldrich', cursive;
}
I know this is an old thread, but I thought I'd offer another answer... A solution I've used is to detect the OS using js, and set a class on the body denoting the OS.
//Windows
if (navigator.appVersion.indexOf("Win") != -1){
document.getElementsByTagName("body")[0].classList.add("win");
}
//Mac
else if (navigator.appVersion.indexOf("Mac") != -1){
document.getElementsByTagName("body")[0].classList.add("mac");
}
Then in your css you can make special rules for the specific scenarios you need:
.some-class-name{
margin-top: 3px;
}
.mac .some-class-name{
margin-top: 5px;
}
Different browsers have different CSS presets, or defaults. Therefore the default rendering will vary. In order to get around this problem, you can use a CSS reset stylesheet. Here is one that works well:
http://meyerweb.com/eric/tools/css/reset/
Using a reset stylesheet will remove any browser defaults. You can then add in your own margin/padding styling. This may require some adjustments to your current CSS values, but it will help overall when making your CSS cross-browser compatible.