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.
Related
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
I'm trying to figure out why I can't fill this spot, despite trying many things I have been unable to figure out how to fix it. I tried padding the top, but to no avail. I have provided the code below as well as a picture of the space I'm talking about. In the picture there's a white space between the header 2 and the gray area that has a brief summary. I have tried padding and also increasing the height of the background color, but it doesn't seem to work. Thank you in advance for reading this and I really do thank you for taking the time to help me figure this out.
$(document).ready(function()){
$("figure img + figcaption").prev().addClass('hasCaption');
});
.body{
margin: 0px;
}
.homeButton{
width: 40px;
}
#MidPort{
background-image: url("http://www.geocities.ws/spahealthcare/pic/dark-green-home-button.png");
background-size:cover;
position:absolute;
margin-left:1565px;
bottom:10px;
}
.topnav{
font-size: 20px;
font-family: Times New Roman;
position:fixed;
top 0;
width:100%;
}
#bg2{
background-color:red;
}
ul{
list-style-type:none;
margin:0;
padding:0;
overflow: hidden;
background-color: #333
}
li{
float:left;
border-right:1px solid #bbb;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: red;
}
.active{
background-color:#4CAF50;
}
li a:hover:not(.active)
{
background-color: #111;
}
li:last-child{
border-right:none;
}
#margintop1{
margin-top: .5cm;
font-family: Gadget;
}
.jumbotron{
height:175px;
background-color:#808080;
}
hr.style17 {
border-top: 1px solid #8c8b8b;
text-align: center;
}
hr.style17:after {
content: '§';
display: inline-block;
position: relative;
top: -14px;
padding: 0 10px;
background: #f0f0f0;
color: #8c8b8b;
font-size: 18px;
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
transform: rotate(60deg);
}
img.hasCaption {
padding-bottom: 50px;
}
figcaption {
position: absolute;
left: 14px;
right: 14px;
bottom: 16px;
background-color: white;
text-align: center;
color: blue;
font-family: 'Reenie Beanie', cursive;
font-size: 30px;
padding: 10px;
}
figure {
display: inline-block;
position: relative;
left: 0;
-moz-transform:rotate(-5deg);
-webkit-transform:rotate(-5deg);
-ms-transform:rotate(-5deg);
transform:rotate(-5deg);
}
img {
border-color: white;
border-width: 15px;
-moz-border-image: url(http://tobias-reinhardt.de/img/frame.png) 15 stretch;
border-image: url(http://tobias-reinhardt.de/img/frame.png) 15 stretch;
border-style: solid;
margin: auto;
}
#imgR{
margin-left:1285px;
height:400px;
}
font{
font-family:Gadget;
}
section{
background-color:#00FFFF;
margin-bottom:10cm;
font-family:Gadget;
}
}
<!-- Check to see if the navigation bar remains at the bottom if I use the nav class instead of ul. If not, revert back to ul for when the user scrolls down-->
<div>
<header>
<!--<div class="container">-->
<h2 class="topnav" id="cs2">
<ul>
<li><a class="active" href="/home">Home</a></li>
<li>About Me</li>
<li>Contact</li>
<li id="MidPort"></li>
</ul>
</h2>
</header>
</div>
<body>
<div class="intro-text">
<div class="jumbotron">
<div>
<p id="margintop1"style="margin-right:200px;">
<font color="white">Front-End Developer and Economist, with experience in project management, machine learning, and leadership roles; devoted to functional programming and analyzing mathematical models to solve emerging economic problems
</font>
</p>
<hr class="style17"/>
</div>
<figure>
<img src="http://i.maniadb.com/images/artist/116/116122.jpg" id="imgR">
</figure>
</div>
</div>
<div id="midSec">
<section>
<h2>
<center>
<font color="#2F4F4F" size="20">
Portfolio
</font>
</center>
</h2>
</section>
</div>
</body>
<!--setup a home button at the bottom-->
[![Space is in between Portfolio and the brief summary][1]][1]
You're using an h2 in your code that has a margin.
h2{margin: 0;}
This will fix it.
h2{margin-top:0}
will fix the issue
h2 by default has a margin top . Remove that.
Also, your HTML is not correct . ( that's why i post this as an answer, to explain to the op the problems from his html )
The biggest problem is that you nested ul inside h2 . This practice is not valid.
As stated in the doc
Most elements that are categorized as phrasing content can only contain elements that are themselves categorized as phrasing content, not any flow content.
Heading tags like h1,h2 etc. are pharsing content, ul is a flow content . So you cannot put ul inside h2
You can check your HTML here > HTML validator and check docs here > documentation
Second problem is that you write <li>About Me</li>
So you first open li, then a but you close first the li and then the a. You need to close the a before closing the li. a being a child of li . Correct form :
<li>About Me</li>
Another problem is using tags that are no longer supported in HTML5 . font,center . ( also the use of size is not supported either) You either use inline styles for example <h2 style="font-size:10px;text-align:center"> or you can use CSS styles separately .
These are just the problems i see from a first look over your code
I'm currently following a UDemy course where the instructor is teaching us Full Stack Development from scratch. Problem is, he made a lot of mistakes that I needed to improvise on like adding <span> next to sign in, instead of his idea of a <p> and my screenshots of the BBC Logo and Sign In button needed it's height modified in order for them to fit properly in that small nav bar.
Here is the code:
<!DOCTYPE html>
<html>
<head>
<title>Wadson's BBC</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<style type="text/css">
body {
margin: 0px;
padding: 0px;
font-family: Helvetica, Arial, sans-serif;
}
#topbar {
background-color: #7A0000;
width: 100%;
height: 45px;
color: #fff;
}
.fixedwidth {
width: 1050px;
margin: 0 auto;
}
#logodiv {
padding-top: 15px;
float: left;
border-right: 1px solid #990000;
padding-right: 10px;
}
#signindiv {
font-weight: bold;
font-size: 0.9em;
border-right: 1px solid #990000;
position: relative;
width: 200px;
height: 45px;
float: left;
}
#signindiv img {
position: relative;
top: 15px;
left: 15px;
}
#signintext {
position: relative;
top: 10px;
left: 25px;
}
#topmenudiv {
float: left;
}
#topmenudiv ul {
margin: 0px;
padding: 0px;
}
#topmenudiv li {
list-style: none;
font-weight: bold;
font-size: 0.9em;
border-right: 1px solid #990000;
padding: 15px 20px 0px 20px
}
</style>
<body>
<div id="container">
<div id="topbar">
<div class="fixedwidth">
<div id="logodiv">
<img src="images/logo.png" height="25px" />
</div>
<div id="signindiv">
<img class="signinhead" src="images/signin.png" height="20px"/><span id="signintext">Sign In</span>
</div>
<div id="topmenudiv">
<ul>
<li>News</li>
<li></li>
<li></li>
</ul>
</div>
</div>
</div>
</div>
</div> <!-- /#container -->
</body>
</html>
Any suggestions for an aspiring programmer? How can I think much differently so that I can spot errors while his is talking instead of copying his stuff verbatim? I understand HTML very well, I'm getting stuck on position, margin and padding.
There is a few things wrong with the code here, I'm not going to go too deep into structure or how using a CSS framework is a great option for beginners(I highly recommend bootstrap and following a tutorial to understand how they use each component as well following a up to date CSS tutorial).
A few quick pointers to fix the problems your border was going past the #topbar because the list items were being stacked vertically instead of horizontally. This was fixed by adding float: right; to the #topmenudiv li. You need to offset the padding you have on your list item elements by setting a height - the padding in this case 30px.
Check the updated version below and always try to include a codepen or jsfiddle with your answer whenever possible.
http://codepen.io/anon/pen/VLEENL
As I understand your question:
Any suggestions for an aspiring programmer? How can I think much differently so that I can spot errors while his is talking instead of copying his stuff verbatim? I understand HTML very well, I'm getting stuck on position, margin and padding.
Use the CSS property outline When you apply it to a class, tag, or id of an element(s), it looks like the CSS property border. The difference between border and outline is that outline will not affect the area surrounding the element(s) which mikes it perfect for seeing your divs and their actual position.
Place this css under your body rule (ie body {...}) in the <style> block:
CSS
/* body * { outline: 1px solid blue; } */ /* Uncomment to see all elements */
.green { outline: 2px dashed green } /* Highlight in green */
.black { outline: 3px dotted #000; } /* Highlight in black */
.yellow { outline: 4px double #fc0; } /* Highlight in yellow */
In order to handle padding and margins easier put the following at the top of your CSS:
CSS
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
This will unify all of the elements under one box-sizing rule. An element's dimensions, padding, and border are included to the element's content. Normally by default (content-box), only width and height are considered. See this for more on box-sizing
Hey all I posted a question earlier here : Why am I getting white space between my HTML element? which was solved.
I have continued working on this page and have ended up with the following:
IE Screenshot:
http://postimage.org/image/2aqd5k99g/
Chrome Screenshot:
http://postimage.org/image/1xdm95138/
What I really want is basically the chrome screenshot but without the white space below my red footer. What can I do to get this desired effect for both IE and Chrome?
My HTML file is:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="swaggersstyle.css">
<title>Oamaru Backpackers Hostel, Swaggers Backpackers - Home</title>
</head>
<body>
<img src="final.jpg" id="banner"></img>
<ul id="nav">
<li class="links">Home</li>
<li class="links">Planning</li>
<li class="links">Construction</li>
<li class="links">Evaluation</li>
</ul>
<div id="mainc">
<p>Make Yourself at Home</p>
<p>Swaggers Backpackers is a converted old house located within walking distance of all the best parts of Oamaru. Explore the old victorian era buildings and shops of the city centre, or see the penguin colonies down the street. Swaggers is owned and operated by camp mum Agra, who makes all guests feel welcome, informed, and perhaps a bit mothered. </p>
</div>
<div id="rightcolumn">
<p>hghadgadgadg</p>
<p>easfasf</p>
<p>safSFS</p>
<p>afafafadf</p>
<p>safasf</p>
<p>saasfasf</p>
<p>fasfsaf</p>
</div>
<div id ="footer">
<p> fsafasfasf </p>
</div>
</body>
</html>
and my CSS file is:
html{
font-family: sans-serif;
background-color:#464E54;
}
body{
width: 960px;
margin: auto;
background-color: white;
border: 5px solid black;
}
#banner{
padding: 0px;
margin: 0;
display: block;
}
#nav {
list-style-type: none;
padding: 0px;
margin: 0px;
overflow: hidden;
}
#mainc {
float: left;
width: 760px;
background-color: white;
margin: 0;
}
#rightcolumn {
padding-left: 3px;
float: left;
background-color: #dad8bf;
width: 197px;
}
#footer {
clear: both;
background-color: red;
}
.links {
float: left;
margin: 0px;
}
a:link {
display: block;
width: 232px;
font-weight: bold;
color: #444444;
background-color: #dad8bf;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
margin-top: 0px;
}
a:visited {
display: block;
width: 232px;
font-weight: bold;
color: #444444;
background-color: #dad8bf;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
margin-top: 0px;
}
a:hover {
background-color: #999999;
}
a:active{
background-color: #999999;
}
Once again cheers for everyones help - hopefully after this I will be a bit more familiar to these mysterious white lines showing up.
add the following rule
div#footer p {
margin:0;
}
Use inspect element on chrome by right clicking.
you will find the area which is blue by moving mouse over the respected area and then you can solve the problem
Have you checked it on different chrome browsers (From different PCs chrome browsers) or do you have any download manager extension installed on your browser, if yes; then disable that first and then reload your page.
Hope this works for you.
Many of these problems are solved, only by importing and using a CSS Reset. Why don't you use them?
Theory: Browsers apply some default style on HTML elements, and they are not the same in that. For example, IE might add 15px margin to p elements, while Chrome might add 13px. This means that incosistencies can exist between default styles of HTML elements across browsers. CSS Reset is technically a set of CSS rules which zero-outs these default values. For example, you can see that in CSS reset, a p is directed to have 0 margin.
p
{
margin: 0;
}
This is what the weird view looks like, in Chrome on OS X on first load:
That blue bar running right across the screen is actually the navigation bar that should be at the top of the screen. See below.
This is what the original view looks like, and this is what it reverts to - once I scroll down (so that portion of the screen disappears) and scroll back up:
Edit1: I don't even know what code to post, if any because it is kinda random. If you ask some questions though, maybe something might jump out and I will know what code to either post or look at.
Thanks.
Edit2: Here is the code for the div#navigation:
<div id="navigation">
<div id="quota-info">
Plan: Chameleon<br />
# of Projects: 2 / 20<br />
# of Clients: 2 / 15<br />
Storage: 10.8 MB / 10.0GB <br />
</div>
<div id="user-info">
<span class="username">Hi Test</span><br />
Name: Test User<br />
Email: test#abc.com<br />
Last Logged In: about 2 hours ago<br />
</div>
<ul>
<li><img src="logo.png" /></li>
<li id="dashboard">Dashboard</li>
<li id="settings">Settings</li>
<li id="logout">Logout</li>
</ul>
</div>
Here is the CSS:
#navigation {
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
background: #2d343f;
background-image: url('../images/nav-textured-bg.png');
background-repeat: repeat;
padding: 5px 5px;
margin: 0px auto;
position: relative;
height: 75px;
}
#navigation a {
text-decoration: none;
padding: 10px 15px;
display: inline;
height: 35px;
line-height: 35px;
color: #c6c8cb;
}
#navigation ul {
width: 100%;
margin: 0 auto;
text-align: center;
}
#navigation li {
width: 100%;
display: inline;
list-style-type: none;
}
#navigation li img {
position: relative;
top: 15px;
}
Edit 3:
Here is another screenshot of how it looks when I scroll up. The top navigational bar is still there. This blue thing is not even the menu, it's like a screenshot of it. When I hover over the menu links, they don't work.
You have to create a reduction. Start with a copy of the actual page and then remove stuff not related to the problem, one by one, until it disappears. Then you'll see what's causing it, whether it's a browser bug and what you can do to fix it.
PS: If it's a browser bug, don't neglect to report it. It's a web developer's responsibility.
I would start by cleaning up some of your CSS.
#navigation {
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
background: #2d343f;
background-image: url('../images/nav-textured-bg.png');
background-repeat: repeat;
padding: 5px 5px;
margin: 0px auto; <--- see below
position: relative;
height: 75px;
}
this should be margin:0 since it's a block element. Block elements take up the entire line, so trying to center it makes no sense.
#navigation a {
text-decoration: none;
padding: 10px 15px;
display: inline; <--- conflict (see below)
height: 35px; <--- conflict (see below)
line-height: 35px;
color: #c6c8cb;
}
Inline elements can't have a width or height applied to them, but some browsers when you try to will automatically convert any inline element to inline-block for you. If that is what you want, you should specify it, otherwise drop the height.
#navigation ul {
width: 100%;
margin: 0 auto; <-- see below
text-align: center;
}
Centering an item with 100% width does not make sense here
#navigation li {
width: 100%; <--- conflict
display: inline; <--- conflict
list-style-type: none;
}
#navigation li img {
position: relative;
top: 15px;
}