Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

I'm having trouble link my css file

Featured Replies

I've got the html and the css files open.

 

in the css i've got:

 

@charset "utf-8";

body {

background-attachment: fixed;

background-image: url(Images/gradient-380x1050.jpg);

background-repeat: repeat-x;

background-position: left top;

}

div {

background-image: url(Images/Maincontent-practice.jpg);

background-repeat: no-repeat;

background-position: center;

position: absolute;

}

 

So the background I want is showing up, but the second part (the div) isn't showing up at all.

If I put anything else in it like specify the font, nothing happens either...

 

So it is linked but now what.

ARGH

 

Also what is that bit at the top (@charset "utf-8";)

 

Thanks

try position: relative; for your div rather than position: absolute;

 

currently its content will decide the height, if you have no text, or the text is not as high as your background image, you'll have to specify a height (and a width) for the div.

  • 4 weeks later...

Hmmm, have you tried linking your HTML file correctly to your CSS files using the following head section "<head> </head>".

 

HTML Head Example

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

 

CSS Example

body {
background-attachment: fixed;
background-image: url(Images/gradient-380x1050.jpg);
background-repeat: repeat-x;
background-position: left top;
}
#div {
background-image: url(Images/Maincontent-practice.jpg);
background-repeat: no-repeat;
background-position: center;
position: absolute;
}

 

Once thats done then make sure you have given your div's the right discription - 'class' (e.g- .text_style) or 'id' (e.g - #header_div).

 

Hope this helps :)

Hi,

 

In your CSS you say the following.

 

div {
background-image: url(Images/Maincontent-practice.jpg);
background-repeat: no-repeat;
background-position: center;
position: absolute;
}

 

Is the DIV your trying to style called 'div'?

 

If so you should be doing the following:

 

#div {
background-image: url(Images/Maincontent-practice.jpg);
background-repeat: no-repeat;
background-position: center;
position: absolute;
}

 

Notice the '#' sign.

  • 2 weeks later...

All of this still depends on the HTML as bocaj has already spotted.

 

it's all well and good having the correct CSS, but it still won't show if the HTML is wrong.

 

Show us the HTML you're trying to use with it and we'll be able to tell you exactly where things are going wrong.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.