How to show multiple radioButtons in two columns - html

I am showing radio buttons dynamically in two columns. As you can see in picture
It looks fine in few conditions but sometimes when text is large it looks off. How can I resolve this issue
Here is some code:
.radiobox-padding-top{
padding-top:15px;
}
input[type=radio] {
float: left;
display: block;
margin-top: 4px;
}
label {
margin-left: 15px;
display: block;
}
here is html code (I am using angular)
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 col-xl-8 remove-padding question-row-face">
<div class="col-12" >
<p class="grey-text inlineBlock question-padding">{{data.help_text}}</p>
</div>
<div class="row" style="margin: 0px">
<div class="col-12 radiobox-padding-top">
<div class="form-group">
<span *ngFor="let entry of options; index as i">
<div class="col-5 inlineBlock">
<div class="radio">
<input type="radio" name="{{data.slug}}" checked value="{{options[i]}}">
<label>
{{options[i]}}
</label>
</div>
</div>
</span>
</div>
</div>
</div>
</div>

I have created a running stackblitz.
Modify your code like this:
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 col-xl-8 remove-padding question-row-face">
<div class="col-12" >
<p class="grey-text inlineBlock question-padding">{{data.help_text}}</p>
</div>
<div class="row" style="margin: 0px">
<div class="col-12 radiobox-padding-top">
<div class="form-group">
<div class="row">
<div class="col-6" *ngFor="let entry of options; index as i">
<div class="inlineBlock">
<div class="radio">
<input type="radio" name="{{data.slug}}" checked value="{{options[i]}}">
<label>
{{options[i]}}
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Additionally change your CSS like this:
.radiobox-padding-top{
padding-top:15px;
}
input[type=radio] {
float: left;
margin-top: 4px;
}
label {
padding-left: 5px;
margin-left: 15px;
display: block;
}
For more informations about bootstrap breakpoints have a look here.

Related

Highlight the label item after clicking on checkbox

I am trying to display the cards as input type is a checkbox, on selecting the cards I am able to fetch the details what are cards selected by the user, and my requirement is I required to highlight the card which is selected by the user.
for example, I need to highlight the card whose checkbox is checked, and if the checkbox is unchecked I need to show as the card.
lable+input[type=checkbox]:checked {
//some css code
}
<form [fromGropu]="form1">
<label for="{{i}}" *ngFor="let item of items" ;let i=index ">
<input type="checkbox " id="{{i}} " [value]="item " (change)="onchange() "/>
<div class="card rounded-0 ">
<div class="card-header ">{{item.header}}</div>
<diva class="card-body>{{item.desc}}</div>
<div class="card-footer">{{item.footer}}</div>
</div>
</div>
</label
</form>
but above CSS is not working, could anyone help on this
After input checked, the div.card following input should apply the css.
Your css should be like this
input[type=checkbox]:checked + div.card{
color: red;
}
Demo https://stackblitz.com/edit/angular-checked-input?file=src/app/app.component.css
Why not just highlight using a class which is toggled using ngClass? please try this change.
<form>
<label for="{{i}}" *ngFor="let item of items;let i =index" (click)="item.active = !item.active;"
[ngClass]="item.active ? 'active' : ''" style="display:block;">
<div class="card rounded-0">
<div class="card-header">{{item.header}}</div>
<div class="card-body">{{item.desc}}</div>
<div class="card-footer">{{item.footer}}</div>
</div>
</label>
</form>
Note: please delete this active property for the array used if you are sending the data to any API. Below is a working example!
Stack Blitz Demo
.services input[type="checkbox"] {
display: none;
}
.services label {
height: 100%;
padding: 10px;
margin: 0px;
border-radius: 0.55rem;
}
.services input[type="checkbox"]:checked + label {
background: #20df80;
}
.services input[type="checkbox"]:checked + label::after {
font-family: "Font Awesome 5 Free";
font-weight: 900;
border: 2px solid #1dc973;
content: "\f00c";
font-size: 24px;
position: absolute;
top: -25px;
left: 50%;
transform: translateX(-50%);
height: 50px;
width: 50px;
line-height: 50px;
text-align: center;
border-radius: 50%;
background: white;
}
.services img{
max-width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class='container mt-5'>
<div class="row services">
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="24 Horas" name="type[]" value="5" checked>
<label for="24 Horas">
<br>
<h5 class="card-title"><strong>24 Horas</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="Aire acondicionado" name="type[]" value="4">
<label for="Aire acondicionado">
<br>
<h5 class="card-title"><strong>Aire acondicionado</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="Bar" name="type[]" value="8">
<label for="Bar">
<br>
<h5 class="card-title"><strong>Bar</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="Buffet" name="type[]" value="3" checked>
<label for="Buffet">
<br>
<h5 class="card-title"><strong>Buffet</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
</div>
</div>

bootstrap placeholder not working on a input type

I have a HTML which has a div with multiple inputs(with placeholder). For some reason the placeholder is not displayed properly.Also, need the 2 input button(text) to be placed next to each other.
Here is the jsfiddle.
http://jsfiddle.net/o2qt6910/
HTML
<div class="container">
<div class="row row-bordered voffset4">
<div class="col-md-12">
<label class="radio-inline"><input type="radio" name="optradio">Aisles</label>
<label class="radio-inline"><input type="radio" name="optradio">Poses</label>
<label class="radio-inline"><input type="radio" name="optradio">Exclusion Zones</label>
</div>
</div>
<div class="row row-bordered">
<div class="col-md-4">
<button type="button" class="btn" id="add-aisle">Add</button>
<div id="aisle-coordinate-container">
<div class="col-md-1"> <input type="text" class="form-control" id="inputKey" placeholder="X"> </div>
<div class="col-md-1"> <input type="text" class="form-control" id="inputValue" placeholder="Value"> </div>
</div>
</div>
<div class="col-md-8">
<canvas id="myCanvas"></canvas>
</div>
</div>
<!--<div class="row">-->
<!--<img src="/static/images/lena.png" alt="Italian Trulli">-->
<!--</div>-->
</div>
CSS
#import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css";
.row-bordered:after {
content: "";
display: block;
border-bottom: 5px solid #ccc;
margin: 0 25px;
}
.voffset { margin-top: 2px; }
.voffset1 { margin-top: 5px; }
.voffset2 { margin-top: 10px; }
.voffset3 { margin-top: 15px; }
.voffset4 { margin-top: 30px; }
.voffset5 { margin-top: 40px; }
.voffset6 { margin-top: 60px; }
.voffset7 { margin-top: 80px; }
.voffset8 { margin-top: 100px; }
.voffset9 { margin-top: 150px; }
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
Try this:
<div class="row row-bordered">
<div class="col-md-4">
<div class="col-xs-12">
<button type="button" class="btn col-xs-2" id="add-aisle">Add</button>
</div>
<div id="aisle-coordinate-container">
<div class="col-sm-6">
<input type="text" class="form-control" id="inputKey" placeholder="X">
</div>
<div class="col-sm-6">
<input type="text" class="form-control" id="inputValue" placeholder="Value">
</div>
</div>
</div>
<div class="col-md-8">
<canvas id="myCanvas"></canvas>
</div>
</div>
There is some issue in Fiddle in alignments. I've tested this in my browser, input elements are now in one line with placeholders visible properly.
<div class="row row-bordered">
<div class="col-md-4">
<button type="button" class="btn" id="add-aisle">Add</button>
</div>
</div>
<div class="row">
<div id="coordinate-container">
<div class="col-md-3 col-sm-3"> <input type="text" class="form-control" id="inputKey" placeholder="X"> </div>
<div class="col-md-3 col-sm-3"> <input type="text" class="form-control" id="inputValue" placeholder="Value"> </div>
</div>
</div>
<div class="col-md-8">
<canvas id="myCanvas"></canvas>
</div>
</div>
Is this how you want it to be? I'm having a hard time visualising what is it that you want.
Do you want the add button and the inputs on the same line or next?
Edit: Changed the button to be on another row. There is no need for it to be on the same row, if you want it on another line.
Its not an issue with the code but more how you are using the bootstrap grid. Your parent container has col-md-4 but the div with the input boxes have col-md-1 which only 1/4th of the width to be shown so its squished down. If you remove the col-md-1 classes it shows up correctly.
Quick suggestion: If you want to use a col-md-x class you can add row class to the <div id="coordinate-container">

aligning text box label with the text box

I'm using bootstrap. I want the text labels for the inputs to be aligned left of the text boxes edge, not above in the center as they are now.
Is this something that is done with bootstrap?
EDIT: Sorry the code snippet did not show my problem properly so i redid it in jsFiddle.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="text-center col-xs-12 ">
<div class="row">
</div>
<div class="row ">
<div class="col-xs-6 ">
<label for="companyInput">LABEL</label>
<br />
<input id="companyInput" type="text">
</div>
<div class="col-xs-6 ">
LABEL
<br />
<input id="cardInput" type="text" />
</div>
</div>
</div>
EDIT:
I updated your fiddle, here - https://jsfiddle.net/Lfmxt3kv/1/
If you have to have text-center on the parent container, then you'll need a wrapper div around your label and input element. Here are the changes I made to the fiddle:
<div class="text-center col-xs-12">
<div class="row ">
<div class="col-xs-6 ">
<!-- .input-wrapper needs to be wrapped around both the label and input element -->
<div class="input-wrapper">
<label for="companyInput">LABEL</label>
<input id="companyInput" type="text">
</div>
</div>
<div class="col-xs-6 ">
<div class="input-wrapper">
<label for="cardInput">LABEL</label>
<input id="cardInput" type="text" />
</div>
</div>
</div>
</div>
.input-wrapper {
display: inline-block;
text-align: left;
}
.input-wrapper label {
display: block;
}
Just adding text-left looks like it works.
<div class="col-sm-6 text-left">
LABEL ONE
<br />
<input id="companyInput" type="text" placeholder="Företag... (1-100)">
</div>
you are looking for Bootstrap forms
Individual form controls automatically receive some global styling.
All textual <input>, <textarea>, and <select> elements with
.form-control are set to width: 100%; by default. Wrap labels and
controls in .form-group for optimum spacing.
For what you want, you need to display:inline-block the .form-group and add class text-left to align left because .container has text-center
Snippet
.form-group {
display: inline-block
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="text-center container">
<div class="row">
<div class="col-xs-12">
<form class="form">
<div class="form-group text-left">
<label for="companyInput">Company</label>
<input class="form-control" id="companyInput" type="text" placeholder="Företag... (1-100)">
</div>
<div class="form-group text-left">
<label for="cardInput">Card</label>
<input class="form-control" id="cardInput" type="text" placeholder="Kort... (1-100)" />
</div>
</form>
</div>
</div>
</div>
for a quick fix you could add a class to the div..
<div class="textalign col-span-6">
then in css just do
.textalign { text-align: left; }

HTML renders undefined line through element?

The following code generates 3 boxes with a glyphicon icon, text and title. (NOTE: with the JSFiddle, you need to have the display window in the medium+ size bracket to generate the correct layout). These are responsive and use the bootstrap framework. When I preview the result, I sometimes get a line under the glyph. What is causing this? I get it in both Google Chrome and Microsoft Edge, however, sometimes when I zoom in, it disappears, then if I zoom in more, it reappears? Other times when I load the same file, it doesn't show.
<div class="row Page2">
<div class="col-sm-2 margin"></div>
<div class="col-sm-2 col-xs-2">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-bullhorn glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-1 margin"></div>
<div class="col-sm-2 col-xs-2">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-ok glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-1 margin"></div>
<div class="col-sm-2 col-xs-2">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-phone glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-2 margin"></div>
<div class="col-sm-2 margin"></div>
<div class="col-sm-2">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h3><strong>Simple</strong></h3>
</div>
<div class="col-xs-6 col-sm-12 eqheight1">
<p class>Text.</p>
</div>
</div>
</div>
</div>
the css:
.Page2 > * {
border: 5px solid white;
background: #3DBEAF;
}
.Page2 > *:nth-child(-n+6) {
border-bottom: 0;
padding-top: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.Page2 > *:nth-last-child(-n+6) {
border-top: 0;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.eqheight1,
.eqheight2,
.eqheight3 {
background: #3DBEAF;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
Any ideas, or know how I can test this further?

Nested Columns / Rows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm having a tough time with nested columns in my layout. In the following code snippet the col-md-3 floats above the other two grids using a negative margin. Everything looks fine except for when I try to add text to one of the nested columns, and then it expands out of the row. Any idea what could be causing this? I have a feeling I've made a number of mistakes with my code and I'd appreciate some suggestions on how to tackle this problem.
div {
background-color: grey;
}
.schedule-box-header {
font-size: 32px;
color: #1cbbb4;
text-transform: uppercase;
}
.schedule-box-sub-header {
font-size: 20px;
color: #747474;
text-transform: uppercase;
}
.schedule-box-top {
background-color: #1cbbb4;
height: 5px;
margin-bottom: 10px;
}
.schedule-box-bottom {
background-color: #1cbbb4;
}
.schedule-box-bottom h3 {
text-align: center;
padding: 10px;
color: #ffffff;
}
<div class="container content-wrap drop-shadow">
<div class="row row-buffer">
<div class="col-md-3">
<img class="img-responsive center-block" src="http://placehold.it/350x150">
</div>
<div class="col-md-5 company-name">
<h1>WINE REVIEWS</h1>
<h2>HOME OF THE REVIEWS</h2>
</div>
<div class="col-md-3 schedule-box drop-shadow">
<div class="row">
<div class="col-md-12 schedule-box-top"></div>
</div>
<div class="row">
<div class="col-md-4">
<img class="img-responsive" src="http://placehold.it/350x150">
</div>
<div class="col-sm-8">
<h1 class="schedule-box-header">Expandskskjsfs
<h2 class="schedule-box-sub-header">one time thing</h2>
</div>
</div>
<div class="row row-buffer-small">
<div class="col-md-12 forms">
<div class="form-group">
<input type="email" class="form-control input-date" placeholder="Pick a Date">
</div>
<div class="form-group">
<input type="email" class="form-control input-time" id="email" placeholder="Pick a Time">
</div>
<div class="form-group">
<input type="email" class="form-control input-group" placeholder="Group Size">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 schedule-box-bottom">
<h3>Schedule</h3>
</div>
</div>
</div>
<div class="col-md-1"></div>
</div>
JS Fiddle: http://jsfiddle.net/xbwstdv7/1/
you mean the text "Expandskskjsfs"? If yes it overflows the container because there is no space so by default it will show the text in one row even if it overflows the container.
You could use in your css:
.schedule-box-header {
word-break: break-all;
}
that will break the word when text reach the end of its container.