CSS no background image, any ideas? - html

I'm trying to get my background image to show at the top center of the page. The image works fine if I do:
<style>
body {
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed;
}
</style>
I can't seem to work out where I've gone wrong. There must be something I've managed to mess up, I just can't see it. Here is the CSS:
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('img/top_logo_blank_small.png') no-repeat fixed;
color: #fff;
margin: 0;
padding: 0;
}
a {
color: black;
text-decoration: none;
}
/* Typography */
.header h1 {
position: absolute;
width:100%;
top: 50%;
margin-top: -20px;
text-align: center;
letter-spacing: 4px;
}
.header h1 em {
font-size: 1.200em;
font-style: normal;
}
h1 {
font-size: 2.2em;
color: #fff;
}
.content h2 {
font-size: 1.75em;
color: #fff;
letter-spacing: 4px;
text-align: center;
}
.content h2 em {
font-size: 1.2em;
font-style: normal;
}
.content h3 {
text-align: center;
font-size: 1.0em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
margin-bottom: 25px;
}
.content h4 {
margin-top: 0;
text-align: center;
font-size: 0.8em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
}
#banner p {
text-align: center;
}
/* Navigation */
#nav {
margin: 4px 4px 40px;
}
#nav ul {
padding: 0;
margin: auto;
list-style: none;
}
#nav ul li {
width: 50%;
color: #BBB;
float: left;
font-family: 'Cabin Sketch';
font-size: 1.75em;
text-align: center;
background: url(img/scribble_dark.png);
}
#nav ul li a {
display: block;
/*padding: 5px 20px;*/
}
#nav ul li a:hover {
background: #e0d0e0;
}
/* Content */
.container{
max-width: 720px;
margin: 50px auto 0;
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed 0 0;
}
.header {
position: relative;
background-color: #b88fb8;
border-top: 5px solid #ede0ed;
height: 75px;
}
.content {
background-color: #000;
padding: 15px;
margin-bottom: 10px;
}
div#about {
padding:25px;
min-height: 255px;
}
img#portrait {
float: left;
margin-right: 25px;
width: 256px;
height: 256px;
}
div#footer {
width: 100%;
max-width: 720px;
margin: auto;
color: black;
text-align: right;
padding: 0 10px;
font-size: 0.850em;
}
#media screen and (max-width: 650px) {
.container {
width: 90%;
max-width: none;
}
div#footer {
width: 90%;
}
}

Try to change your path for example:
background: #EEE url('../img/top_logo_blank_small.png') no-repeat fixed top;
Because you are in a subfolder, you have to go up of a level I think

Most likely your css file is in a different folder and therefore needs another path to the image file.
The common way is to put css in a separate css/* folder, so the path should be:
url('../img/top_logo_blank_small.png')

This CSS seems to work fine, are you certain that the image exists?
http://jsfiddle.net/ghsNR/
I've just tried it here and it works fine with an image from http://placehold.it/
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('http://placehold.it/500x500') no-repeat fixed top;
color: white;
margin: 0px;
padding: 0px;
}
The most likely cause after observing this is that your CSS isn't actually locating your image correctly. I suggest using tools like the Chrome dev tools, or Firebug to inspect the absolute path that the browser is trying to use to load the image and moving forward from there.

Is the css in the same folder as the page? If you have a different folders, you need to change the URL accordingly.
Maybe change the URL to
'../img/top_logo_blank_small.png'

Related

My page seems to have right padding or margin when scaled further down?

My site is fine until I go lower than 723px wide then a white margin appears on the right side of all of my background colors. I have tried to go in and delete margins and padding to see where I have gone wrong. I also played with the width of the elements and it just stretches the image over the visible portion when I set the image to full. I've inspected the page and can not define the white space on the page and where it comes from.
I also tried adding display:inline-block; to my css background divs as well as setting the width: 100%.
CSS
body {
margin: 0;
font-family: 'Comic Neue', sans-serif;
}
main {
margin-top: none;
}
.hero_image {
background-image: url("C:/Users/Kascey.Malone/Documents/Websites/Midterm/images/669.png");
height: 100vh;
width: 100%;
position: relative;
background-size: 100% 100%;
display:inline-block;
}
/*NAVIGATION BAR*/
header {
height: fit-content;
}
header a {
font-weight: bold;
color: #FCD90A;
}
header a:link {
text-decoration: none;
}
header a:visited {
text-decoration: none;
}
header a:hover {
text-decoration: underline;
}
header a:active {
text-decoration: underline;
}
.topnav {
overflow: hidden;
text-decoration: none;
}
.left {
padding: 20px;
float: left;
width: 50%;
box-sizing: border-box;
text-decoration: none;
text-align: left;
}
.right {
padding: 20px;
float: right;
width: 50%;
box-sizing: border-box;
text-decoration: none;
text-align: right;
}
/*HERO BOX*/
.hero {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
.hero h1 {
font-size: 15vw;
margin: 0;
text-align: center;
color: #9A1000;
font-style: italic;
}
.hero button {
padding: 1em;
margin-top: 10vh;
background-color: #FCD90A;
white-space: nowrap;
font-size: 1vw;
font-family: 'Comic Neue', sans-serif;
}
.hero button a{
text-decoration: none;
color: black;
}
.hero button a:link {
text-decoration: none;
}
.hero button a:visited {
text-decoration: none;
}
.hero button a:hover {
font-weight: bold;
}
.hero button a:active {
font-weight: bold;
}
.container {
position: relative;
}
.center {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
/*MENU TABLE*/
.table {
background-color: white;
padding-top: 100px;
padding-bottom: 100px;
box-sizing:border-box;
}
table {
margin-left: auto;
margin-right: auto;
padding: 40px;
font-size: 1vw;
background-color: white;
border: solid 8px black;
box-sizing:border-box;
}/*Add border.*/
thead {
text-align: right;
}
td:nth-child(even) {
text-align: left;
padding-left: 100px;
}
td:nth-child(odd) {
text-align: right;
padding: 10px;
}
.row {
display: flex;
margin: 0 auto;
}
table a{
text-decoration: none;
color: black;
} /*Change color based off background*/
table a:link {
text-decoration: none;
}
table a:visited {
text-decoration: none;
}
table a:hover {
text-decoration: underline;
}
table a:active {
text-decoration: underline;
}
th {
padding: 10px;
}
/*ABOUT TEXT*/
.about {
height: auto;
padding-top: 5vh;
padding-bottom: 5vh;
background-color: #3823FC;
background-size: 100% 100%;
}
.column {
flex: 50%;
padding: 10px;
}
.column h2{
font-size: 2vw;
padding-left: 200px;
color: white;
}
.column p{
padding-right: 200px;
padding-top: 88px;
font-size: 1.5vw;
color: white;
}
.column img {
width: 30vw;
padding-left: 200px;
height: auto;
}
/*FOOTER*/
.footer {
background-color: #0C026C;
padding: 10px;
text-align: left;
color: white;
}
Try to use percentages for your padding/margins. Your size is scaling based on screen size with the percentages used.
Another option could be using display: flex; with flex containers.
Here is a helpful document to get you started.
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
You could also use #Media tags in CSS for different screen sizes to fit things manually. Here is a reference to get you started: W3 Schools Reference

make entire image fill background with css

Struggling to write CSS to format the image so that it covers the entire background of the page, as it doesn't seem to be able to do so below. It seems to be getting stuck up on the header and I am not sure how to correct that.
margin-top: 0px;}
h1 a {
background-color: black;
font-size: 40px;
color: white;
margin-left: 40px;
padding: 10px 20px;
letter-spacing: -1px;
text-decoration: none;
font-weight: bold;
}
.sidenav {
width: 150px;
position: fixed;
z-index: 1;
top: 85px;
left: 10px;
/*background: #ffffff;*/
overflow-x: hidden;
padding: 8x 0;
}
.sidenav a {
padding: 4px 1px 4px 40px;
text-decoration: none;
font-size: 25px;
color: #000000;
display: block;
font-weight: bold;
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif';
}
Make the image the background of the body or a div (is how I would do it).
CSS:
body {
background: url("");
}
or
.coolbackground {
background: url("");
}
You can set how it covers the page using:
background-size: ;
and
background-repeat: ;
Else if you dont want to do that, use a float, absolute positioning and z-index.

How do I change link style in CSS?

I know this sounds like an obvious question and answer, but I have spent a long time trying to figure this out, and for some reason, none of the answers are not working for me. Honestly, this is probably going to be a simple obvious answer I just can't catch. But here's the problem: I am making a website out of HTML5, CSS, and some PHP.
The issue is, that my links appear blue and purple with an underline. I know this is how they are supposed to look, but I have tried many different ways to re-style the links with text-decoration: none, and different colors and so on.
Here is my CSS and the HTML part with a link:
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
a {
text-decoration: none;
color: brown;
}
.sidebar {
width: 25%;
height: 100%;
float: left;
background-color: #BC986A;
overflow-y: scroll;
}
.side-option {
width: 100%;
height: 155px;
background-color: #BC986A;
}
.side-option:hover, .side-option:focus {
background-color: #DAAD86;
}
.side-name {
font-family: "Indie Flower", cursive;
font-size: 1.8em;
margin: 2px 2px 0px 7px;
padding: 5px 5px 0px 5px;
}
.side-image {
width: 150px;
height: 97px;
margin: 0px 0px 0px 15px;
border: 0.3em solid #FBEEC1;
}
.info {
background-color: #659DBD;
width: 75%;
height: 100%;
float: right;
}
#name {
font-family: "Gloria Hallelujah", cursive;
font-size: 50px;
text-align: center;
color: #FBEEC1;
}
#s-name {
font-family: "Gloria Hallelujah", cursive;
font-size: 20px;
text-align: center;
color: #FBEEC1;
}
#image {
display: block;
width: 384px;
height: 256px;
margin-left: auto;
margin-right: auto;
border: 0.5em solid #BC986A;
margin-top: 10px;
}
#desc {
font-family: "Rock Salt", cursive;
font-weight: bold;
font-size: 20px;
text-align: center;
color: #DAAD86;
}
<div class="sidebar">
<a href="index.php?page=0"><div class="side-option">
<h2 class="side-name">Brown Bear</h2>
<img src="http://maxpixel.freegreatpicture.com/static/photo/1x/Animal-Brown-Bear-Beast-Bear-Teddy-Bear-Mammal-422682.jpg" class="side-image" alt="Brown bear standing in tall plants.">
</div></a>
I'm not sure if you needed all that, but there it is anyway.
For hover color change you can use this css
.sidebar a:hover{color:red; }
For keep the color focus after click
.sidebar a:focus{color:blue; }
1) You need to change your code from </div></a> at the end to this: </div></a></div>
2)Links can be styled differently depending on what state they are in.:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
You can read more about this in: https://www.w3schools.com/css/css_link.asp
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
a, a:link, a:visited{
text-decoration: none;
color: brown;
}
a:hover, a:active{
color: green;
}
.sidebar {
width: 25%;
height: 100%;
float: left;
background-color: #BC986A;
overflow-y: scroll;
}
.side-option {
width: 100%;
height: 155px;
background-color: #BC986A;
}
.side-option:hover, .side-option:focus {
background-color: #DAAD86;
}
.side-name {
font-family: "Indie Flower", cursive;
font-size: 1.8em;
margin: 2px 2px 0px 7px;
padding: 5px 5px 0px 5px;
}
.side-image {
width: 150px;
height: 97px;
margin: 0px 0px 0px 15px;
border: 0.3em solid #FBEEC1;
}
.info {
background-color: #659DBD;
width: 75%;
height: 100%;
float: right;
}
#name {
font-family: "Gloria Hallelujah", cursive;
font-size: 50px;
text-align: center;
color: #FBEEC1;
}
#s-name {
font-family: "Gloria Hallelujah", cursive;
font-size: 20px;
text-align: center;
color: #FBEEC1;
}
#image {
display: block;
width: 384px;
height: 256px;
margin-left: auto;
margin-right: auto;
border: 0.5em solid #BC986A;
margin-top: 10px;
}
#desc {
font-family: "Rock Salt", cursive;
font-weight: bold;
font-size: 20px;
text-align: center;
color: #DAAD86;
}
<div class="sidebar">
<a href="index.php?page=0"><div class="side-option">
<h2 class="side-name">Brown Bear</h2>
<img src="http://maxpixel.freegreatpicture.com/static/photo/1x/Animal-Brown-Bear-Beast-Bear-Teddy-Bear-Mammal-422682.jpg" class="side-image" alt="Brown bear standing in tall plants."/>
</div>
</a>
</div>
a {
text-decoration: none;
color: brown;
}
is where you need to make changes to edit links
to change hover options:
a:hover {
style it here
}
and for already visited links on your site:
a:visited {
style it here
}
You asked how to style links.
a{
color: red;
cursor: wait;
font-size: 24px;
transition: color 0.3s, text-shadow 0.3s;
text-decoration: none;
}
a:hover{
color: green;
text-shadow: 1px 2px 3px #000;
text-decoration: overline;
}
a:active{
font-weight: 900;
}
Working link.

I accidentally put an extra close curly bracket

I am stuck with an extra close curry bracket in CSS that I accidentally put prior writing other lines. If I leave it there, it acually does no harm to the result. However, when I remove it, the position of other elements are repositioned.
(( In lines of code, the extra close curly bracket is where the arrow pointing ))
Please click on the links below to see both results.
Question: Is there any way to remove it without repositioning other elements?
Without the Close Curly Bracket
With the Close Curly Bracket
body{
font: 15px/1.5 Helvetica, Arial, sans-serif;
padding: 0;
margin: 0;
p(color#282f38);
background-color: #F5F2ED;
font:696863;
}
/*Global*/
.container{
width:80%;
margin:auto;
overflow:hidden;
}
ul{
margin:0;
padding:0;
}
/* Header */
#fixed{
position: fixed;
}
header{
position: fixed;
width: 100%;
background:#282f38;
color:#F5F2ED;
padding-top: 10px;
min-height:50px;
border-bottom:#F5F2ED 3px solid;
}
header a{
color:#F5F2ED;
text-decoration:none;
text-transform:uppercase;
font-size: 18px;
}
header li{
float:left;
display: inline;
padding: 0 20px 0 20px;
}
header #resume{
float: left;
}
header #resume h1{
margin: 0;
padding: 0;
}
header nav{
position: relative;
left: 30%;
float: right;
margin-top: 10px;
}
header .highlight, header .current a{
color:#696863 ;
font-weight: bold;
}
header a:hover{
color:#696863;
font-weight: bold;
}
/* Showcase */
#showcase {
min-height: 350px;
background: url('../Resources/Photographer.png') no-repeat 0 -120px;
align-items: center;
color: #ffffff;
overflow: auto;
}
#showcase h1{
text-align: center;
margin-top: 100px;
font-size: 40px;
margin-bottom: 10px;
}
#showcase p{
text-align:justify;
margin:0;
padding:0;
font-size: 14;
text-indent: inherit;
}
/* Social Medias*/
#socialmedias{
position:fixed;
padding-top: : 5px;
right: 20px;
top: 130px;
display: block;
vertical-align: baseline;
font: inherit;
list-style-type: none;
}
} <<-----------------------------------------------------------------------
/* Message Me Box */
#box{
width: 30%;
overflow: hidden;
padding: 1px;
}
/* Box Border */
.fieldset{
display: inline-block;
border: 3px solid;
float: right;
}
/* Message Me Title */
#legend{
font-size: 20px;
font-weight: bold;
color:#282f38;
}
/* Name Input */
#form-name{
display: block;
width: 200px;
margin-bottom: 10px;
}
/* Email Input */
#form-email{
display: block;
width: 200px;
margin-bottom: 10px;
}
/* Message Input */
#form-message{
display: block;
margin-bottom: 10px;
}
/* Contact */
.button_contact{
position: relative;
height: 30px;
width: 100%;
background:#696863;
color: #F5F2ED;
font-size: 14px;
text-transform: uppercase;
border: 0;
}
The extra curly bracket is being treated as part of the selector for the next rule. i.e. the rule is
} #box {
width: 30%;
overflow: hidden;
padding: 1px;
}
So } #box matches nothing. When you remove the }, the selector is #box and matches the element with id "box".
If you don't want the effect you get when removing the extra }, remove the entire rule.
Not just one error,
Check the comments I added in your code.
Best way to avoid these errors are using an IDE.
There are so many open source tools available. For example NetBeans.
They can help you to identify your errors.
Check this screenshot, they are easy to use also.
/* Social Medias*/
#socialmedias{
position:fixed;
padding-top: : 5px; // Error 1,
right: 20px;
top: 130px;
display: block;
vertical-align: baseline;
font: inherit;
list-style-type: none;
}
} // Error 2
body{
font: 15px/1.5 Helvetica, Arial, sans-serif;
padding: 0;
margin: 0;
p(color#282f38); // Error 3
background-color: #F5F2ED;
font:696863;
}
You have many errors in your css. I've validated your css on W3C CSS Validator
I've changed your CSS. See below:
body {
font: 15px/1.5 Helvetica, Arial, sans-serif;
padding: 0;
margin: 0;
background-color: #F5F2ED;
}
p {
color: #282f38;
}
/*Global*/
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
ul {
margin: 0;
padding: 0;
}
/* Header */
#fixed {
position: fixed;
}
header {
position: fixed;
width: 100%;
background: #282f38;
color: #F5F2ED;
padding-top: 10px;
min-height: 50px;
border-bottom: #F5F2ED 3px solid;
}
header a {
color: #F5F2ED;
text-decoration: none;
text-transform: uppercase;
font-size: 18px;
}
header li {
float: left;
display: inline;
padding: 0 20px 0 20px;
}
header #resume {
float: left;
}
header #resume h1 {
margin: 0;
padding: 0;
}
header nav {
position: relative;
left: 30%;
float: right;
margin-top: 10px;
}
header .highlight, header .current a {
color: #696863;
font-weight: bold;
}
header a:hover {
color: #696863;
font-weight: bold;
}
/* Showcase */
#showcase {
min-height: 350px;
background: url('../Resources/Photographer.png') no-repeat 0 -120px;
align-items: center;
color: #ffffff;
overflow: auto;
}
#showcase h1 {
text-align: center;
margin-top: 100px;
font-size: 40px;
margin-bottom: 10px;
}
#showcase p {
text-align: justify;
margin: 0;
padding: 0;
font-size: 14px;
text-indent: inherit;
}
/* Social Medias*/
#socialmedias {
position: fixed;
padding-top: 5px;
right: 20px;
top: 130px;
display: block;
vertical-align: baseline;
font: inherit;
list-style-type: none;
}
/* Message Me Box */
#box {
width: 30%;
overflow: hidden;
padding: 1px;
}
/* Box Border */
.fieldset {
display: inline-block;
border: 3px solid;
float: right;
}
/* Message Me Title */
#legend {
font-size: 20px;
font-weight: bold;
color: #282f38;
}
/* Name Input */
#form-name {
display: block;
width: 200px;
margin-bottom: 10px;
}
/* Email Input */
#form-email {
display: block;
width: 200px;
margin-bottom: 10px;
}
/* Message Input */
#form-message {
display: block;
margin-bottom: 10px;
}
/* Contact */
.button_contact {
position: relative;
height: 30px;
width: 100%;
background: #696863;
color: #F5F2ED;
font-size: 14px;
text-transform: uppercase;
border: 0;
}
/* Header */
----------------->#fixed{<------------------
position: fixed;
}
Try to change the id where the arrow is pointed, use class for that, because there are so many conflicts, if we use IDs directly. For more information please find the link below:
https://github.com/CSSLint/csslint/wiki/disallow-ids-in-selectors
i think there is something to do with "#fixed" id name in the html and css.
try to change the name to something else. The property and your name might be colliding with each other. So change it...

sticky CSS footer broken

My footer is designed to stay at the bottom of the page even if the div above it only has a small amount of content. It worked until recently, and I seem to have broken it somehow.
Can you take a look?
Thanks in advance.
CSS:
body {
margin: 0;
padding: 0;
height: 100%;
font: 100% Helvetica, sans-serif, Arial, sans-serif;
color: #000;
background-color: #FFF;
background-image: url(images/BGmain.png);
background-repeat: repeat-x;
}
/*----------
Div styles
----------*/
#container {
min-height: 100%;
position: relative;
}
.header {
padding: 0 0 230px 0;
text-align: center;
background-image: url(images/BGlogo_55top.png);
background-repeat: no-repeat;
background-position: top;
}
.column1 {
padding-bottom: 50px;
width: 960px;
margin: 0 auto;
position: relative;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
}
/*----------
Other
----------*/
.plainimg {
border-style: none
}
/*----------
Text styles
----------*/
p {
font-size: 80%;
color: #333;
line-height: 150%;
text-align: left;
padding: 1px 15px 1px 15px;
}
h1 {
font-size: 100%;
color: #000;
padding: 0;
}
h2 {
font-size: 100%;
font-weight: 500;
color: #000;
padding: 0;
text-align: center;
}
/*----------
Links
----------*/
a.navlink:link, a.navlink:visited {
text-decoration: none;
display: inline-block;
color: #F1F1F1;
width: 120px;
text-align: center;
padding: 0 0 3px 0;
font-size: 80%;
}
a.navlink:hover, a.navlink:active {
text-decoration: none;
display: inline-block;
color: #FFF;
background-color: #000;
width: 120px;
text-align: centre;
padding: 0 0 3px 0;
font-size: 80%;
}
a:link, a:visited {
text-decoration: none;
color: #AEAEAE;
}
a:hover, a:active {
text-decoration: underline;
color: #999
}
The div arrangement is as follows:
<div id=container>
<div class=header></div>
<div class=column1></div>
<div class=footer></div>
</div>
As Jason McCreary said, you need to add height to the html CSS.
Use:
html
{
height: 100%;
margin: 0;
padding: 0;
}
On your pages this triggers an extraneous scrollbar for some reason.
UPDATE:
The scrollbar appears to be triggered by the overflow of the .footer h6.
Adding: bottom: 2.5ex; and line-height: 1; to the footer style appears to clears that.
But a better way is to use a CSS reset.
With no reset, at the minimum, add:
.footer h6 {
margin: 0;
padding: 0;
}
.
A CSS reset will also minimize cross-browser variation that busts the layout from platform to platform.
Take a look at this: http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page
When it has broken for me in the past I typically have something in the content that is the culprit - padding, invalid markup, etc. If you post a link to your page, you may find a more specific answer.
Here is your problem:
#container {
min-height:100%;
position:relative;
}
Here is the fix:
#container {
min-height:100%;
}
Good stuff:
http://www.w3schools.com/Css/pr_class_position.asp
Solved. Easy Solution Just put your Footer Division outside of your Container Division.
<div id=container>
<div class=header></div>
<div class=column1></div>
</div>
<div class=footer></div>