Newbie HTML5 & CSS3 issue with Locating some icons - html

I am new to HTML5 & CSS and New since HTML when it first came to life
Anyhow I am working on learning how to code in HTML5 & CSS3 at the moment.. but have ran into a road block...
I want to get my Copy right information on the left of the footer background and my browser icons to the right of my footer background.... I have been playing with the problem for 9 hours I don't give up easily even tried some suggestions I found here which did not work...
If you would like to see actual page you can goto
http://cowboy0629.ddns.net/test
.mainFooter {
width: 97%;
float: left;
height: 40px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background-color: #141476;
margin: 2% 1.5% 2% 1.5%;
}
.footerIcons img.chrome {
width: auto;
height: 20px;
}
.footerIcons img.firefox {
width: auto;
height: 23px;
}
.footerIcons img.safari {
width: auto;
height: 23px;
}
.footerIcons {
float: right;
height: 9px;
}
.footerIcons ul {
float: right;
padding: 0;
margin: 0 auto;
}
.footerIcons li {
float: right;
list-style:none;
margin-left:5px;
}
.footerIcons span p {
height: 20px;
float: left;
color: #3399FF;
width: 97%;
margin: 9px;
}
<footer class="mainFooter">
<div class="footerIcons">
<span>
<p>Copyright © 2017 cowboyDesigns.com</p>
</span>
<ul>
<li>
<img class="chrome" src="images/icons/black-chrome-icon.png" alt="">
</li>
<li>
<img class="firefox" src="images/icons/black-firefox-icon.png" alt="">
</li>
<li>
<img class="safari" src="images/icons/black-safari-icon2.png" alt="">
</li>
</ul>
</div>
</footer>

You could use relative positioning on the <ul> element.
.footerIcons ul {
position: relative;
top: -47px;
}
This might be a sloppy solve than doing something like setting the container size to 30% and getting div alignment.

The solutions above will fix the issue but they seem more likely to be hacks,
p and ul are block elements and they won't be in the same line by default.
you need to replace the existing CSS rules with the set the CSS as below
.mainFooter p {
color: #3399FF;
display: inline-block;
margin: 9px;
}
.mainFooter ul {
display: inline-block;
float: right;
list-style: none;
margin: 0 auto;
}
.mainFooter img {
width: 30px;
height: 30px;
margin: 5px;
}
there is no need for separate rules for each browser icon and use icons of same width and height.

Just change the float setting to left in .floatericons in the css file for the copyright part.
.footerIcons {
float: left;
height: 9px; }
Add this part:
.footerIcons ul {
position: relative;
top: -47px;
left:600px;
float:right;}

There's multiple ways I can think of to accomplish this.
This works:
<footer class="mainFooter">
<ul>
<li style="float:left">Copyright © 2017 cowboyDesigns.com</li>
<li style="float:right"><img class="chrome" src="images/icons/black-chrome-icon.png" alt=""></li>
<li style="float:right"><img class="firefox" src="images/icons/black-firefox-icon.png" alt=""></li>
<li style="float:right"><img class="safari" src="images/icons/black-safari-icon2.png" alt=""></li>
</ul>
</footer>
It could use a little love with regards to vertical alignment, but it works.
I wouldn't set links in navigation bars to display:inline because it makes them harder to click (since they don't fill up the block around them)...I also use utility CSS float classes, not inline styles.
Floats and positioning are one of the hardest things to learn in CSS but there's an easy and fast way to get it sorted out.
Check out this video on using Chrome DevTools as an IDE
Not only can you see the changes in real time, you can even map them back to your source files so changes you make are saved.
Or you could just use a framework that has solutions for things like this baked right in. I'm a big fan on Foundation and the grid and alignment classes would be well-suited to this problem.
It seems you're doing this for school so maybe you can't use a framework but you can look at how they solved the problem and what code they used.

Just building on top what you have created you will have something similar to this:
footer {
width: 97%;
height: 40px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background-color: #141476;
margin: 2% 1.5%;
}
footer p,
.footerIcons{
line-height: 20px;
margin: 9px;
}
footer p{
float: left;
color: #3399FF;
}
.footerIcons {
float: right;
}
.footerIcons img.firefox,
.footerIcons img.safari,
.footerIcons img.chrome{
width: auto;
height: 23px;
}
<footer>
<p>Copyright © 2017 cowboyDesigns.com</p>
<div class="footerIcons">
<img class="chrome" src="images/icons/black-chrome-icon.png" alt="">
<img class="firefox" src="images/icons/black-firefox-icon.png" alt="">
<img class="safari" src="images/icons/black-safari-icon2.png" alt="">
</div>
</footer>

Related

First element in Body tag is hard-stuck on top left corner

I've been having an issue with every single CSS exercise so far where the first element inside my body tag, whether it's an img or an h1 is simply stuck at the top left corner of the page (where the body tag starts, I assume) and it's just impossible to move it in any way, regardless of margin size or element width. I even tried adding a background color to it just to see if it would work and it didn't, so i guess that for some reasons, no modifications can be made to this element.
Here's my HTML
<body>
<header class="Top">
<img src="img/logo.png" alt="NeoDance Logo" width="356" height="48" class="logo">
<nav class="NavBar">
Home
About
Class schedules
Performances
Blog
Contact
</nav>
<div class="ClearFix"></div>
</header>
Here's my CSS. Note that before this displayed line, I'm using a completely unedited version of the Meyer css reset
header.Top{
width: 1440px;
margin: auto;
background-color: #303030;
overflow: hidden
}
div.wrapper
img.Logo{
margin-top: 35px;
margin-bottom: 35px;
margin-left: 250px;
margin: auto;
background-color: #303030;
}
nav.NavBar{
float: right;
width: 490px;
background-color: #303030;
list-style: none;
margin: auto;
margin-right: 250px
}
a.links{
float: right;
font-size: 15pt;
font-family: 'Muli', sans-serif;
color: #8c8c8c;
margin-top: 50px;
margin-right: 18px;
}
div.container 1{
width: 490px;
clear: both
}
img.dancers{
float: right;
}
div.ClearFix{
clear: both;
}
That img.logo should have margins applied, as specified in the css. However it's just stuck there, shown in the image below
Problem
I'm guessing you're talking about your logo, and not the actual header element.
For one, your css selector is wrong. It should be img.logo instead of img.Logo
Also, remove that div.wrapper code from your css. What's that doing there? Then remove the margin: auto from your img.logo style and you're good to go.
The order of declaration in CSS is important (hence the "Cascading").
Therefore, when you do :
img.Logo{
margin-top: 35px;
margin-bottom: 35px;
margin-left: 250px;
margin: auto;
background-color: #303030;
}
margin:auto overrides all of the margins above.
You should try to put margin:auto before the other margins and it should work.

How to remove the white gap between the background image and the navigation bar

I am by no means an expert in HTML or CSS. I am fairly new, and have little experience. I have come across and issue and I am not sure how to fix it. As you can see from the JSFiddle (linked below) there is a white gab between the image and the navigation bar. The image is a background-image created in CSS. I would like to remove the gap so that the image is flush with the navigation bar.
I have tried changed the values for the margin and padding of the #headerimage div as well as the #nav div. I know if I make the margin-top a negative value, it can fix the problem, but that is a very clunky solution because I would constantly have to change that value if I increase font size or anything like that. I have also search stackoverflow for similar problems, but none of them fixed my problem.
I also realize that I probably could have done many things differently in terms of how I coded some things, again I am new. The following code is the HTML code, the next block is the CSS code. Sorry if I did not explain something well, if you require more information, I will try my best to elaborate further on the issue. Thank you guys so much for taking the time to look at my issue. All the best. If you notice anything else, whether it a possible error, or just not a good solution for something, I would love to here about it.
<html>
<head>
<link rel="stylesheet" type="text/css" href="about.css">
<title>Sean Anderson</title>
</head>
<body>
<div id="container">
<div id="nav">
<ul>
<li>About</li>
<li>Achievements</li>
<li>Academics</li>
<li>Contact</li>
</ul>
</div>
<div id="headerimage">
<h1>SEAN ANDERSON</h1>
</div>
<div id="whoami">
<h2>WHO AM I?</h2>
<ul>
<li>I am a student at SFS High School</li>
<li>I am an aspiring programmer</li>
<li>Comics, books, programming, casual gaming</li>
<li>4.0 GPA</li>
<li>Star Wars is my life</li>
</ul>
<img src="testbackground.jpg">
</div>
<div id="skills">
<h2>SKILLS</h2>
<ul>
<li>Familiar with Java, HTML, and CSS</li>
<li>Skilled with Microsoft Office Suite 2013</li>
<li>Skilled in math, science, and English</li>
<li>Awesome</li>
</ul>
</div>
<div id="footer">
<p>Copyright © 2015 Sean Anderson</p>
</div>
</div>
</body>
</html>
body {
font-family: Helvetica, sans-serif;
width: 100%;
background-color: white;
margin-left: 0px;
margin-top: 0px;
}
#container {
width: 100%;
background-color: white;
margin-top: 0px;
}
#nav {
background-color: black;
margin-bottom: 0px;
}
#nav ul {
list-style-type: none;
padding: 30px 0px 30px 0px;
text-align: center;
margin-top: 0px;
margin-bottom: 0px;
min-width: 1920px;
}
#nav li {
display: inline;
text-align: center;
}
#nav a {
text-decoration: none;
text-align: center;
color: white;
font-size: 30px;
padding: 30px 50px 30px 50px;
}
#nav a:hover {
background-color: white;
color: black;
}
#headerimage {
background-image: url("testbackground.jpg");
background-repeat: repeat;
height: 1000px;
width: 100%;
margin-top: 0px auto;
display: block;
clear: both;
}
#headerimage h1 {
text-align: center;
vertical-align: middle;
padding-top: 150px;
}
Here is the JSFiddle: http://jsfiddle.net/Seanathon98/3nw5wj1d/
(The image takes up the whole width on my monitor, not sure why is doesn't appear that way, as I did use width: 100%.
Set the margin and padding of the H1 element to 0.
h1 {
margin: 0;
padding: 0;
}
You can center the h1 element by setting its position to be absolute and use padding & margin to position it correctly;
#headerimage h1 {
position: absolute;
margin: -20px 0 0 0;
padding: 50% 0 0 0;
}

CSS3 Content and wrapper div wont auto Resize

HTML
<div id="nav">
<div id="nav_wrapper">
<ul>
<li>Home</li><li>
Licensing</li><li>
About us</li><li>
Testimonials</li><li>
Contact Us</li><li>
Social <img src="image/arrow.png" width="8" height="4" />
<ul>
<li><img src="image/social/YouTube.png" width="32" height="32" title="Youtube" /></li>
<li><img src="image/social/Twitter.png" width="32" height="32" title="Twitter"></li>
<li><img src="image/social/Facebook.png" width="32" height="32" title="Facebook"></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<img src="image/placeholderimg.png">
<h2>Overview</h2>
<p>Filler Text</p>
</div>
</div>
CSS3
#content
{
margin-left: auto;
font-family: Arial, Helvetica, sans-serif;
resize: both;
}
#content p
{
max-width: 1100px;
margin: 0;
color: #ccc;
min-width: 960px;
}
#content h2
{
margin: 0;
color: #ccc;
min-width: 960px;
}
#content img
{
float: left;
padding-right: 20px;
padding-bottom: 20px;
}
#wrapper
{
min-width: 960px;
width: 50%;
margin: auto;
}
Fixed CSS3 Code
#content
{
padding-top: 10px;
font-family: Arial, Helvetica, sans-serif;
resize: both;
}
#content p
{
max-width: 1100px;
margin: 0;
color: #ccc;
min-width: 960px;
}
#content h2
{
margin: 0;
color: #ccc;
min-width: 960px;
}
#content img
{
float: left;
padding-right: 20px;
padding-bottom: 20px;
}
#wrapper
{
min-width: 960px;
width: 50%;
margin: auto;
}
So I've been going around looking for a fix to this, but it seems like i can't find one... So I've come to ask the more seasoned programmers here at Stack-overflow. My Problem i have is need need the content div to re-size along with the rest of the elements, but i cant seem to do it properly. I don't want to completely cut it out using overflow, I want it to shrink along with the page re-size. Is there anyway of doing it? Provided above is the css3 code along with the html divs I'm trying to re-size. The main divs I'm trying to re-size is the content, or the wrapper as an over all if possible.
Edit: For some reason or the other I did something I cant explain that fixed the code, could some be so kindly and explain to me what I did?
width:auto;
Once try applying this to your code along with "min-width".. i don't know whether it works or not, but once give it a try..
The CCS3 property for "resize" allows the user to drag and resize the content div. You should use;
width: auto;
or you could use;
width: 100%;
Check out the fiddle. You do not need to set the widths of p or h tags. They usually take up the full space.
Setting the containers to width: 100% should do it.
http://jsfiddle.net/92gnt7qt/4/
#nav {width: 100%;min-width: 960px;}
#nav_wrapper {width: 100%;}
#content
{
width: 100%;
min-width: 960px;
}
If your parent has a min-width of 960px and the children have widths of 100%, the children will still only go to 960px.
It seems by removing
margin: auto;
It some how auto configured it to what I wanted it to do. Would anyone be able to help me understand this?

Placing Images in the css file instead of the html file

For my header I'm using the ul and li tags for my nav menu (Portfolio/Contact/About) I'm trying to place the images text (Portfolio/Contact/About) and the slashes in the CSS file instead of my div "navigationMain" in the HTML file but every attempt I tried has failed. Is there a certain way dealing with ul, li tags and placing images within the tags using CSS? Because I've placed my logo and header background in the header within the css file. Also I'm creating this website in notepadd++
http://jsfiddle.net/J4h9Q/7/embedded/result/ http://jsfiddle.net/J4h9Q/8/
HTML:
<div class="header">
<div class="container">
<div class="headerMain"> </div>
<div class="navigationMain">
<ul class="nav">
<li><img src="images/portfolio2.png" alt="portfolio" id="portfoliobutton"></li>
<li><img src="images/slash.png" alt="slash"></li>
<li><img src="images/about.png" alt="about" id="aboutbutton"></li>
<li><img src="images/slash.png" alt="slash"></li>
<li id="contactbutton" class="contact"><img src="images/contact.png" alt="contact"></li>
</ul>
</div>
</div>
CSS:
body,div,ul,li,p{
margin:0;
padding:0;
}
html,body {
margin:0;
padding:0;
}
body{
margin:0;
padding:0;
height:100%;
background: url(../images/background11.png) repeat scroll 0 0;
}
.header {
background: black;
height: 165px;
min-width: 1075px;
}
.container {
height: 165px;
margin-left: auto;
margin-right: auto;
width: 1075px;
}
.headerMain{
height: 165px;
position: relative;
width: 195px;
float: left;
left: 20px;
top: 4px;
background:url(../images/ARlogo8.png) no-repeat center center;
}
.navigationMain{
height: 154px;
margin-left: auto;
margin-top: -4px;
position: relative;
width: 665px;
right: 30px;
}
li{
display: inline;
}
.nav li{
display: inline;
color:white;
position: relative;
top: 70px;
font-family: "Century Gothic", CenturyGothic, AppleGothic, sans-serif;
left: 160px;
font-size:44px;
}
How tied are you to putting the images in CSS? I recommend putting the slashes, if anything, in the CSS. That would immediately reduce the number of list items down to 3 - so it's more "semantic". You should not have a list item just to denote a slash.
Demo: http://jsfiddle.net/YBzA9/1/
Feel free to tweak the dimensions in .nav a when you use your real images.
After you reduce the number of list items, consider one of the following:
(easy solution) putting the images inside of anchor tags in the markup and calling it a day
(a more "correct" solution) styling your anchor like such:
HTML
<ul>
<li>Portfolio</li>
<li>About</li>
<li>Contact</li>
</ul
CSS
.nav li {
background: url('http://dummyimage.com/26x34/000000/fff&text=//');
padding-left: 26px;
}
.nav li:first-child {
background: none;
}
.nav a {
display: block;
text-indent: -999px;
height: 35px;
width: 120px;
}
#portfolio-link {
background: url('http://dummyimage.com/146x35/000000/fff&text=Portfolio');
}
#about-link {
background: url('http://dummyimage.com/146x35/000000/fff&text=About');
}
#contact-link {
background: url('http://dummyimage.com/146x35/000000/fff&text=Contact');
}
This allows text to still be read (search engines, screen readers) but still maintain visual appeal.
You could set that images as background without repeating it. You also need to set a min height and width to be sure that you can see the image later. You can also store the image in the css file if you store it base64 encoded.
In general I would just fix the links to your images. Try using absolute urls beginning with a single slash.

Why CSS is cropping the bottom of my image?

I have a logo and text on the page and my items are floated left but this causes the bottom of the logo to cut off. No minus margins or paddings are used. Looking with XRAY and webdeveloper style finder I see that the img is getting cut short with no other elements around it, (it is just floated left). If I remove the float from the .logo the image appears whole, but larger and out of position
Here is the jsfiddle http://jsfiddle.net/9LGRx/ It seems to be a FF bug, works ok in Chrome and Safari.
html > body > header > div.wrapper > a.logo > img
HTML code
<header>
<div class="wrapper">
<a href="/" class="logo">
<img src="images/logo.png" alt="Showhouse logo">
</a>
<h1>Welcome to ShowHouse</h1>
<p class="text">
Show off your property management skills with ShowHouse - the only online property
management software that will effortlessly handle and help to improve every aspect of
your <strong>residential</strong> and <strong>commercial lettings</strong>, <strong>sales</strong> and <strong>block management</strong>.
</p>
</div>
</header>
SCSS Code
h1{
color: #fff;
float: left;
clear: both;
}
img{
max-width: 100%;
float: left;
}
header{
background-image: url('../images/header-bg.jpg');
float: left;
width: 100%;
/*height: 417px;*/
.logo{
float: left;
width: 60%;
margin: 20px 0 20px 0;
}
.logo img{
max-width: 100%;
}
.text{
float: left;
clear: both;
color: $color-white;
font-size: 1.2em;
margin-top: -10px;
}
}
Try adding this to your css:
.logo img{
max-width: 100%;
display: block;
height: 150px;
}
(put the real height of your image or the height you want to display)