Reputation: 2669
I am trying to styling a form in which I have got a radio button. I want to change the default view of the radio button and add background image for the radio button and for the check image. Moreover I want to place my form in the center of the screen and highlighted with a line. My code is here in jsfiddle:
<style>
form{
font-size: 200%;
font-family: "Courier New", Monospace;
display: inline-block;
align: middle;
text-align: center;
font-weight: bold;
background-size: 20px;
}
input[type="radio"] {
width: 26px;
height: 26px;
background: url(check.png) no-repeat;
}
</style>
http://jsfiddle.net/chrathan/q1mnq2os/2/1
How can I perform those operations?
Upvotes: 0
Views: 1183
Reputation: 22643
Try this
*{box-sizing: border-box}
form{
font-size: 200%;
font-family: "Courier New", Monospace;
text-align: center;
font-weight: bold;
width: 320px;
margin: 0 auto;
background-size: 20px;
}
input[type="radio"] {
width: 26px;
height: 26px;
visibility: hidden;
display: none
}
label{
position: relative;
margin-right: 40px
}
label:after{
content: '';
position: absolute;
right: -40px;
top: 0;
cursor: pointer;
width: 32px;
height: 32px;
border: 2px solid blue;
border-radius: 50%;
}
input[type="radio"]:checked + label:after{
background: red; /*add your background image here*/
}
<form class = "form" action="action2.php" method="post">
<a href=' .$user. ' style=\"text-decoration:none;\"> "' .$user. '" </a><br><br>
<p>
<input type="radio" name="classif" id="C1" value="true" checked="checked" hidden />
<label for="C1">FASHION</label>
</p>
<p>
<input type="radio" name="classif" id="C2" value="false" hidden />
<label for="C2"> NON FASHION </label>
<input type="hidden" name="imageName" value="' . $line . '">
</p>
<input type="submit" value="submit" />
</form>;
Upvotes: 1
Reputation: 15699
Centering form:
Remove
display:inline-block
and add:
margin:0 auto
to form.
This is a nice link for styling radio button.
Upvotes: 1