How can i draw a box in css? I want a box like the green one used to display the number of answers to a question in stackoverflow?
+2
A:
Use any element – e.g. a div
, make sure it's displayed as a block-level element (i.e. display: block
) and give it a border.
.box { border: 1px solid #088; font-size: 4em; }
<div class="box">6</div>
Works well.
Konrad Rudolph
2008-12-30 13:39:45
+1
A:
CSS:
.answerbox
{
height: 150px; /*Specify Height*/
width: 150px; /*Specify Width*/
border: 1px solid black; /*Add 1px solid border, use any color you want*/
background-color: green; /*Add a background color to the box*/
text-align:center; /*Align the text to the center*/
}
HTML:
<div class="answerbox">4 <br /> Answers</div>
Jon
2008-12-30 13:45:49
+5
A:
Use Firebug and the "Inspect" function; point at the answer box here on SO and rip the HTML and CSS from the Firebug console.
stian
2008-12-30 14:35:53
Thanks for that tip :)
Chris Serra
2008-12-30 15:03:56
A:
this page: http://www.w3.org/TR/CSS2/box.html
was the first page found by doing a Google search for "css box"
John Ferguson
2008-12-30 14:44:04
A:
You can also use the AIS Accessibility Toolbar - http://www.visionaustralia.org.au/ais/toolbar/ - to expose the css used for the site amongst a whole host of other stuff.
Peanut
2008-12-30 14:53:51