Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the button into the top right corner inside the div box

Tags:

html

css

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:

enter image description here

#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>
like image 633
John Smith Avatar asked Sep 11 '13 20:09

John Smith


People also ask

How do I put the button on the right side of a 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)

Can I put a button inside a div?

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 do I put something in the top right corner in CSS?

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.

How do you put a button in the top right corner of bootstrap 5?

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.


1 Answers

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

like image 135
j08691 Avatar answered Oct 01 '22 09:10

j08691