Jump to content

Recommended Posts

HTML option 1

<div style="background-color: #FFFFFF;border: 1px solid #333333;height:300px;width:400px;margin-left:auto;margin-right:auto;">
wtg wegt wtg werg werg  grw er gw e5g wet grwertrg</div>

 

HTML option 2

<div class="complete">
werg werg werg werg werg wergwer gwer wef fwe fe w</div>

 

html option 1 with the inline css works. option 2 with the css in the style sheet doesn't.

 

The CSS in the style sheet:

.complete{
background-color: #FFFFFF;
border: 1px solid #333333;
height:300px;
width:400px;
margin-left:auto;
margin-right:auto;
}

 

 

I haven't got a clue why option 2 is not working, could anyone help?

Link to comment
https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/
Share on other sites

<link href="css styles sticky.css" rel="stylesheet" type="text/css" />

 

in the head.

 

 

The way it is linked cannot be the problem though as there are loads of other things on the page that linked that work.

 

It's just this "complete" class

You have spaces in your filename? Try not to add any spaces within filepaths. It is best practice to substitute spaces with either an underscore (_) or a hyphen (-). Alternatively you could use camel case, eg CssStylesSticky.css

 

The link tag should be between the <head></head> tags. It may be helpful if you posted your actual HTML rather than snippets.

wildteen88, thanks. I simply replaced the spaces in the filename with underscores and bingo it worked! It's weird though that all the other references to the .css worked fine (about 25 pages worth!)

 

Eitherway, thanks a bundle, you've solved my problem  :D

I thought i had had solved this problem, with the help of wildteen, but it just occured again.

 

I'm not sure how it resolved its self this time but it did.

 

I was wondering, does the browser store the css stylesheet in its history? This would explain why how sometimes when i make a change it doesn't change on the site.

It depends on your server settings, but yes, generally css files are cached by the browser.

 

To do a had refresh of your page (i.e. use nothing from the cache, and get everything fresh from the server), hold shift and click the refresh button (or in most browsers you can hold ctrl and click F5, though this doesn't work in at least Safari, maybe other smaller browsers as well).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.