/    Sign up×
Community /Pin to ProfileBookmark

How to input a text below of ”radio-image” without misaling.

Hi Guys.

I’ve tryed many forms to do it, but i can’t do it.

I just need to put a text below of five images, like: “1 – so angry”, “2 – bad”, etc. But when i put a broken line
“<br>” my layout misalign, because i need to put two images on the same line
and in my .css i have: display: inline-block.

Example of i need:

[upl-image-preview url=https://www.webdeveloper.com/assets/files/2020-02-20/1582165204-913805-note.png]

when i put <p> </p> it broke two lines and misalign everything.

I need 2 images by line.

My code in html is:

[code]

<fieldset class=”radio-image”>

<label for=”1 – so angry”>
<input type=”radio” name=”qualifica” id=”1 – so angry” value=”1 – so angry” required>
<img src=”imagens/note1.png”><b>1 – so angry</b></label>


<label for=”2 – bad”>
<input type=”radio” name=”qualifica” id=”2 – bad” value=”2 – bad” required>
<img src=”imagens/note2.png”><b>2 – bad</b></label>


<label for=”3 – kind of”>
<input type=”radio” name=”qualifica” id=”3 – kind of” value=”3 – kind of” required>
<img src=”imagens/note3.png”><b>3 – kind of</b></label>

<label for=”4 – good”>
<input type=”radio” name=”qualifica” id=”4 – good” value=”4 – good” required>
<img src=”imagens/note4.png”><b>4 – good</b></label>

<label for=”5 – very good”>
<input type=”radio” name=”qualifica” id=”5 – very good” value=”5 – very good” required>
<img src=”imagens/note5.png”><b>5 – very good</b></label>

</fieldset><br>

[/code]

My code in .css is:

[code]

.radio-image label > input{
visibility: hidden;

}
.radio-image label > input + img{
width: 30%;
display: inline-block;
cursor:pointer;
border:4px solid #EEE;
border-radius:15px;
padding:10px;
}
.radio-image label > input:checked + img{
border:4px solid #3F51B5;
}

[/code]

Can anyone help me? Thanks a lot.

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumFeb 20.2020 — @fabiojac#1614956 You can center image and text by use of `text-align: center;`

I applied additional modifications to your code, mainly using the figure tag, and now the layout looks like your image.

HTML:
&lt;fieldset class="radio-image"&gt;
&lt;label for="1 - so angry"&gt;
&lt;input type="radio" name="qualifica" id="1 - so angry" value="1 - so angry" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;1 - so angry&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="2 - bad"&gt;
&lt;input type="radio" name="qualifica" id="2 - bad" value="2 - bad" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;2 - bad&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="3 - kind of"&gt;
&lt;input type="radio" name="qualifica" id="3 - kind of" value="3 - kind of" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;3 - kind of&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="4 - good"&gt;
&lt;input type="radio" name="qualifica" id="4 - good" value="4 - good" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;4 - good&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="5 - very good"&gt;
&lt;input type="radio" name="qualifica" id="5 - very good" value="5 - very good" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;5 - very good&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;

<i> </i>&lt;/fieldset&gt;


CSS:
.radio-image {
text-align: center;
}

<i> </i> .radio-image figure {
<i> </i> text-align: center;
<i> </i> margin: 0;
<i> </i> }

<i> </i> .radio-image label {
<i> </i> margin: 5%;
<i> </i> width: 40%;
<i> </i> display: inline-block;
<i> </i> }

<i> </i> .radio-image label&gt;input {
<i> </i> visibility: hidden;
<i> </i> }

<i> </i> .radio-image img {
<i> </i> width: 30%;
<i> </i> display: inline-block;
<i> </i> cursor: pointer;
<i> </i> border: 4px solid #EEE;
<i> </i> border-radius: 15px;
<i> </i> padding: 10px;
<i> </i> }

<i> </i> .radio-image label&gt;input:checked+figure&gt;img {
<i> </i> border: 4px solid #3F51B5;
<i> </i> }
Copy linkTweet thisAlerts:
@fabiojacauthorFeb 20.2020 — @Sempervivum#1614963 Thanks for your help. It almost works.

I used:

<figure>

<img src="images/buttonleftp.png">

<figcaption>1 - so angry</figcaption>

</figure>

But, i need to create two <fieldset>. The first is: Select your note, and the second fieldset is select your genre (male or female), and when i put two fieldsets on my HTML i just can select the note or de genre. When i choose genre ''male'' automatcly the fieldset ''note'' is deselected...

Do you know what can i do?

I've tryed modify names, but a don't know what can a ido for it works perfectly...

Thanks again. :)
Copy linkTweet thisAlerts:
@SempervivumFeb 20.2020 — You need to assign different names to the radiobuttons in the different fieldsets as a group of radiobuttons is defined by their name.
Copy linkTweet thisAlerts:
@fabiojacauthorFeb 20.2020 — @Sempervivum#1614983


Let me show you my code:


<i>
</i>
&lt;fieldset class="radio-image"&gt;
&lt;label for="1 - so angry"&gt;
&lt;input type="radio" name="qualifica" id="1 - so angry" value="1 - so angry" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;1 - so angry&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="2 - bad"&gt;
&lt;input type="radio" name="qualifica" id="2 - bad" value="2 - bad" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;2 - bad&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="3 - kind of"&gt;
&lt;input type="radio" name="qualifica" id="3 - kind of" value="3 - kind of" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;3 - kind of&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="4 - good"&gt;
&lt;input type="radio" name="qualifica" id="4 - good" value="4 - good" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;4 - good&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="5 - very good"&gt;
&lt;input type="radio" name="qualifica" id="5 - very good" value="5 - very good" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;5 - very good&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;

&lt;/fieldset&gt;



&lt;fieldset class="radio-imagetwo"&gt;
&lt;label for="Male"&gt;
&lt;input type="radio" name="genre" id="Male" value="Male" required&gt;
&lt;figure&gt;
&lt;img src="images/male.png"&gt;
&lt;figcaption&gt;Male&lt;/figcaption&gt;
&lt;/figure&gt;

<i> </i> &lt;/label&gt;&lt;label for="Female"&gt;
<i> </i> &lt;input type="radio" name="genre" id="Female" value="Female" required&gt;
<i> </i> &lt;figure&gt;
<i> </i> &lt;img src="images/female.png"&gt;
<i> </i> &lt;figcaption&gt;Female&lt;/figcaption&gt;
<i> </i> &lt;/figure&gt;
<i> </i>
<i> </i> &lt;/label&gt;

&lt;/fieldset&gt;




I also modifyed on the css the name of radio:

<i>
</i>.radio-image img {
width: 250px;
}
<br/>

.radio-image label &gt; input{
visibility: hidden;
}

.radio-image label &gt; input + figure{
width: 250px; <br/>
height: 300px;
display: inline-block;
cursor:pointer;
border:4px solid #EEE;
border-radius:15px;
padding:10px;
}



.radio-image label &gt; input:checked + figure{
border:4px solid #3F51B5;
}





.radio-imagetwo img {
width: 200px;
}
<br/>

.radio-imagetwo label &gt; input{
visibility: hidden;
}

.radio-imagetwo label &gt; input + figure{
width: 250px; <br/>
height: 300px;
display: inline-block;
cursor:pointer;
border:4px solid #EEE;
border-radius:15px;
padding:10px;
}



.radio-imagetwo label &gt; input:checked + figure{
border:4px solid #3F51B5;




I need to change more names of another things?
Copy linkTweet thisAlerts:
@SempervivumFeb 20.2020 — This is missing in your CSS, when I add it, the radiobuttons in the second fieldset work fine.
.radio-imagetwo label&gt;input:checked+figure {
border: 4px solid #3F51B5;
}

I need to change more names of another things?[/quote]
Changing the names for the second group is not necessary and not recommendable as it requiers duplicating the CSS.

This works for me as well:
&lt;!doctype html&gt;
&lt;html lang="en"&gt;

&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Test&lt;/title&gt;
&lt;style&gt;
.radio-image img {
width: 250px;
}

<i> </i> .radio-image label&gt;input {
<i> </i> visibility: hidden;
<i> </i> }

<i> </i> .radio-image label&gt;input+figure {
<i> </i> width: 250px;

<i> </i> height: 300px;
<i> </i> display: inline-block;
<i> </i> cursor: pointer;
<i> </i> border: 4px solid #EEE;
<i> </i> border-radius: 15px;
<i> </i> padding: 10px;
<i> </i> }

<i> </i> .radio-image label&gt;input:checked+figure {
<i> </i> border: 4px solid #3F51B5;
<i> </i> }
<i> </i>&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;fieldset class="radio-image"&gt;
&lt;label for="1 - so angry"&gt;
&lt;input type="radio" name="qualifica" id="1 - so angry" value="1 - so angry" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;1 - so angry&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="2 - bad"&gt;
&lt;input type="radio" name="qualifica" id="2 - bad" value="2 - bad" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;2 - bad&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="3 - kind of"&gt;
&lt;input type="radio" name="qualifica" id="3 - kind of" value="3 - kind of" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;3 - kind of&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="4 - good"&gt;
&lt;input type="radio" name="qualifica" id="4 - good" value="4 - good" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;4 - good&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;&lt;label for="5 - very good"&gt;
&lt;input type="radio" name="qualifica" id="5 - very good" value="5 - very good" required&gt;
&lt;figure&gt;
&lt;img src="images/buttonleftp.png"&gt;
&lt;figcaption&gt;5 - very good&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/label&gt;

<i> </i>&lt;/fieldset&gt;



<i> </i>&lt;fieldset class="radio-image"&gt;
<i> </i> &lt;label for="Male"&gt;
<i> </i> &lt;input type="radio" name="genre" id="Male" value="Male" required&gt;
<i> </i> &lt;figure&gt;
<i> </i> &lt;img src="images/male.png"&gt;
<i> </i> &lt;figcaption&gt;Male&lt;/figcaption&gt;
<i> </i> &lt;/figure&gt;

<i> </i> &lt;/label&gt;&lt;label for="Female"&gt;
<i> </i> &lt;input type="radio" name="genre" id="Female" value="Female" required&gt;
<i> </i> &lt;figure&gt;
<i> </i> &lt;img src="images/female.png"&gt;
<i> </i> &lt;figcaption&gt;Female&lt;/figcaption&gt;
<i> </i> &lt;/figure&gt;

<i> </i> &lt;/label&gt;

<i> </i>&lt;/fieldset&gt;
&lt;/body&gt;


&lt;/html&gt;
Copy linkTweet thisAlerts:
@fabiojacauthorFeb 21.2020 — @Sempervivum#1614988

Finally it works for me. My problem was: imput the tag <legend> </legend> on the begin of the <fieldset>. And the content inside the <legend> </legend> can't be the same on two <fieldset> it needs to be different. So, i hope it can help another people, and i need to say that you helped me a lot. Thank you very much, and sorry my english.
×

Success!

Help @fabiojac spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...