I can't figure out how to get the [X] button into the top right corner of my custom css box.
Here's the result so far:
#wrapper { height: 100px; width: 500px; } #wrapper { bottom: 50%; right: 50%; position: absolute; } #container { background: #FFF; left: 50%; padding: 10px; top: 50%; margin: 0; padding: 0; height: 100%; border: 1px solid rgb(128, 128, 128); height: 100%; position: relative; } #inner1 { height: 100%; border: 1px solid blue; } #inner2 { height: 100%; border: 1px solid green; } #titlebar { cursor: pointer; height: 23px; width: 100%; filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#0A246A, endColorStr=#A6CAF0, GradientType=1); color: white; font: 13px arial, helvetica; } #button { line-height: 12px; width: 18px; font-size: 8pt; font-family: tahoma; margin-top: 1px; margin-right: 2px; }
<div id="wrapper"> <div id="container"> <div id="titlebar">Information Box</div> <div><input id="button" type="button" value="X"></div> </div> </div>
The right side of the button should be x pixels away from the right edge of the div. It should be on the same line as the header. Should be contained in the div (stuff like float or relative positioning pops it out of the div visually)
Use the following steps to center align a button in a div container: Create a div container. Insert the button tag. In the CSS for the div set the text-align to center.
How To Place A Button In Top Right Corner In Css. Insert position:absolute, top:0, right:0, and your CSS into the position:absolute position to display the button.
You can simply use the class . text-right on the containing element to right align your Bootstrap buttons within a block box or grid column.
Just add position:absolute; top:0; right:0;
to the CSS for your button.
#button { line-height: 12px; width: 18px; font-size: 8pt; font-family: tahoma; margin-top: 1px; margin-right: 2px; position:absolute; top:0; right:0; }
jsFiddle example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With