Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: Munchor on September 20, 2011, 01:51:51 pm

Title: Horizontal Fade on both edges
Post by: Munchor on September 20, 2011, 01:51:51 pm
My CSS knowledge is very poor, and so I need help with something.

I need a website to be white on the middle background and fade to gray on the edges. I got an image which is gray fading to white, and made it repeat itself on the left:

Code: [Select]
  background-repeat: repeat-y;

However, I need to achieve the same result (with an inversed image) on the other edge. How can I do it?

Thanks, here's how it should look like (Ascii Art :P)

GgggwwwwwwwgggG

G = Gray, W = white
Title: Re: Horizontal Fade on both edges
Post by: Deep Toaster on September 20, 2011, 07:14:38 pm
Modify the background so it has both sides. That's the only cross-browser solution.
Title: Re: Horizontal Fade on both edges
Post by: Munchor on September 21, 2011, 11:49:12 am
Modify the background so it has both sides. That's the only cross-browser solution.

Thanks, I'll try that. I have another question though... How to achieve a top bar like Facebook.com? I mean, I managed to make a bar, but it's not fully on top and to the right and to the left, it looks like this:

(http://img.removedfromgame.com/imgs/facebookbar.png)

Here's the header (where the text is) HTML and CSS code:

Code: [Select]
<header>
  <img src="titulo.jpg" />
</header>

Code: [Select]

header {
  background-color: #3B5999;
  width: 100%;
  margin-bottom: 20px;
}

The "titulo.jpg" image is the part that says "projeto G". I'd also like a way of controlling how tall the top bar is.

I have "width: 100%", so it's supposed to work alright, but it doesn't really work.
Title: Re: Horizontal Fade on both edges
Post by: flyingfisch on September 21, 2011, 02:44:26 pm
Try this:

CSS:
Code: [Select]
header {
  background-color: #3B5999;
  width: 100%;
  margin-bottom: 20px;
  padding-left: 0px; //overrides most browser's default left padding
}
header img {
    height: 50px; //or whatever you want the height to be
}

P.S. Do you use opera, or is that chrome? cuz thats what the chrome emulator i've got looks like.
Title: Re: Horizontal Fade on both edges
Post by: Deep Toaster on September 21, 2011, 08:07:20 pm
Code: (CSS) [Select]
body
{
margin: 0;
}
Removes the 8-pixel border around everything.
Title: Re: Horizontal Fade on both edges
Post by: Munchor on September 22, 2011, 09:27:22 am
@flyingfisch, the height is now changeable, thanks!

@Deep, that didn't really work (I even used "0px")

I have this:

Code: [Select]
header {
  background-color: #3B5999;
  width: 100%;
  margin: 0px;
  margin-bottom: 20px;
  padding: 0px;
}

header img {
  margin: 0px;
  padding: 0px;
  /* height: 50px */
}
Title: Re: Horizontal Fade on both edges
Post by: Deep Toaster on September 22, 2011, 09:32:55 am
First of all, <header> isn't an HTML tag. You can't just make up your own and assume it'll work, unless you're using XML with style rules.

And I said to put margin: 0 in the body tag, not your header tag.
Title: Re: Horizontal Fade on both edges
Post by: Munchor on September 22, 2011, 09:47:15 am
First of all, <header> isn't an HTML tag. You can't just make up your own and assume it'll work, unless you're using XML with style rules.

And I said to put margin: 0 in the body tag, not your header tag.

<header> is an HTML 5 tag I am very sure. Also "margin: 0;" on "body" worked, thanks!
Title: Re: Horizontal Fade on both edges
Post by: flyingfisch on September 22, 2011, 09:55:41 am
First of all, <header> isn't an HTML tag. You can't just make up your own and assume it'll work, unless you're using XML with style rules.

And I said to put margin: 0 in the body tag, not your header tag.

HTML 5 is not the standard yet, so for best cross-browser support, stay away from too much HTML 5 stuff.

<header> is an HTML 5 tag I am very sure. Also "margin: 0;" on "body" worked, thanks!