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.

PLease help with my CSS and HTML

Featured Replies

Hi

 

Please help me with this one:

 

I have this code in my HTML:

<div>
<img src="logo.jpg" alt="logo" style="float:right; position:fixed; width:55%; height:55px; right:5px" /></div>

 

This works well, it places my logo where I want it.

But as I am now trying to tidy things up by putting all CSS in a separate CSS file, I modify the HTML code to this:

<div id="logo">
<img src="logo.jpg" alt="logo"></div>

 

And I place the CSS in the separate CSS file like this:

#logo {float:right; position:fixed; width:55%; height:55px; right:5px}

 

But if I do this, then my logo goes somewhere unrelated in the page (not the position I indicate it to).

 

What am I doing wrong?

Try

#logo img {float:right; position:fixed; width:55%; height:55px; right:5px}

 

#logo {float:right; position:fixed; width:55%; height:55px; right:5px}

 

 

your missing a semi colon on the end of your css: right:5px

your missing the closing / in the img html you posted

It's a self-closing tag, and is fine.

 

your missing a semi colon on the end of your css: right:5px

Equally, not a problem. It's the last attribute so it doesn't need a semi-colon.

 

Looking at your CSS, you want the logo to be at the top right hand corner of the page regardless of where you are scrolling. I suppose the question I have for this is, is the % for 'width' intentional?

 

<div id="logo"></div>

#logo

{

position:fixed;

width:55px;

height:55px;

right:5px;

top:5px;

background-image:url(path/to/image);

background-position:top right;

background-repeat:no-repeat;

}

 

Regardless of where you are on the page, this will offset your logo from the top right hand corner by five pixels top and right. Could you put up a demo of this template, and an explanation of where you would rather the logo should go?

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.