I want to make bars like this so I could easily add this to my pages.
Wanna make information bars, warning bars etc.
But how would I make this.
Lets say I’ve made this in photoshop, where and what should I slice and about the css part I’m confused at all…
I need best way to make this into css.
What I would do is
Slice the left and right corners.
And the middle part of this.
Then I would make for all these 3 images a div and then do it like
<div id=“leftbar”>
</div>
<div id=“bottombar”>
Text here
</div>
<div id=“rightbar”>
</div>
It depends on what you want exactly and what browsers to support.
You could use border-radius for the corners but IE8 and under will just get square
ones.
If you want to use images for the round corners then it will depend on whether the height of the bar is going to expand with text or not. If the height of the bar is a fixed height and not containing any text (or not containing text that is likely to wrap or overflow) then you could just cap the left and right ends and repeat the middle section (assuming that the background is a gradient otherwise just a background colour will do).
The icon on the left could be a background image or part of a sprite if you have many icons.
It’s hard to tell from that image what the use of that bar is and what it will contain and what height it really is.
You would probably want to nest three divs so that you apply full width repeating background to the first div, then on the inner you add the left side corners and then on the third nested div you add the right side corners.
Your content just goes inside the inner div and floated left and right as required.
If you need varying height then you’ll need to do each individual corner in a rounded box fashion.
Yes as mentioned above text will center if you use text-align:center on the parent. If its a block element you want centered then you would need to use auto margins and a specified width.