html - center radio buttons around div but outside -
can somehow center radio buttons outside of div , @ same time outside body width?
<body> <div class='container'> <div class='box'> <form> <input type="radio" name="points" value="1"> <input type="radio" name="points" value="-1"> </form> <div class='middle'>just div</div> </div> </body> i preferably use kind of css display them left , right of div.
i have created fiddle this: https://jsfiddle.net/qhatn0a8/
i have tried using css left: -100px; how use css right on other button?
i had read twice understand result expected.
you may use position:relative & absolute. in case should use label (and attribute for ) each input link text description.
the idea position wrap both input , text inside label:
body { width: 200px; margin-left: auto; margin-right: auto; margin-top: 0px; } .box { background-color: grey; padding: 10px; margin-bottom: 10px; position:relative;/* added absolute labels */ /* height removed , seems not needed here */ } .middle { background-color: red; } input[type="radio"] { margin-right: 10px; } label {/* use coordonate no need size them */ position:absolute; right:100%; margin:0 1em; white-space:nowrap; } label + label { right:auto; left:100%; } <body> <div class='container'> <div class='box'> <form> <label> <input type="radio" name="points" value="1">point1</label> <label> <input type="radio" name="points" value="-1">point2</label> </form> <div class='middle'>just div</div> </div> <div class='box'> <form> <label> <input type="radio" name="points" value="1">point1</label> <label> <input type="radio" name="points" value="-1">point2</label> </form> <div class='middle'>just div</div> </div> <div class='box'> <form> <label> <input type="radio" name="points" value="1">any text point1</label> <label> <input type="radio" name="points" value="-1">point2</label> </form> <div class='middle'>just div</div> </div> <div class='box'> <form> <label> <input type="radio" name="points" value="1">point1</label> <label> <input type="radio" name="points" value="-1">point2 or text</label> </form> <div class='middle'>just div</div> </div> </div> </body> note: buttons , text can go on other contents aside or go off screen since, in absolute position, off flow ;)

Comments
Post a Comment