How to solve this simple CSS problem?
Page 1 of 1
_SiN_
Megatron



Posts: 12108
Location: Cybertron
PostPosted: Mon, 3rd Jan 2011 10:29    Post subject: How to solve this simple CSS problem?
I'm not a total beginner when it comes to CSS, but I'm not great at it by far either Razz

Having a little problem I've never had to solve before - I've got a logo that has shapes to the left of the text in it, and I want the text-part to be aligned with the layout, but the shapes of the logo to be on the left, like this:



Right now I'm using a container/wrapper in which all DIV's are placed, which has margin-left/right set to auto (I've used this a lot of times for making sure that the site stays centered regardless of browser size).

So basically, everything has to be centered, and the logo has to follow the content when resizing the browser, but with an offset of X number of pixels..


Watercooled 5950X | AORUS Master X570 | Asus RTX 3090 TUF Gaming OC | 64Gb RAM | 1Tb 970 Evo Plus + 2Tb 660p | etc etc
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Mon, 3rd Jan 2011 10:42    Post subject:
Tried negative margins and/or padding? Many ways to achieve this, but it depends on the structure of the rest of the layout. You may also have to explicitly make it a block element. You may also be able to achieve it by setting the logo as background and then shifting it. And there's a few more options besides these
Back to top
_SiN_
Megatron



Posts: 12108
Location: Cybertron
PostPosted: Mon, 3rd Jan 2011 11:31    Post subject:
Hah, solved it. First off, I should NEVER code when I'm as tired as this (first day at work after almost two weeks off = basically no sleep last night).

It's so dead simple, I placed the logo div within the container/wrapper, then set it's position to relative and -120px.. Thanks for reminding me of negative values Razz


Watercooled 5950X | AORUS Master X570 | Asus RTX 3090 TUF Gaming OC | 64Gb RAM | 1Tb 970 Evo Plus + 2Tb 660p | etc etc
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Mon, 3rd Jan 2011 11:39    Post subject:
No problem Smile

As ridiculous as they sound (a negative margin, wut? Razz), they're friggin handy to position some elements in a way that even IE can do it right. That, and display:block; are probably the things I've applied to fix "problems" the most Neutral
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group