How to make a span with glyphicon as a hyperlink? - css

I have some form with glyphicon question mark for field inline tooltip on right:
<div class="form-group required">
<label for="username" class="col-sm-2 control-label">User Name:</label>
<div class="col-sm-3 tooltip-box">
<input id="username" type="text" class="form-control" placeholder="username"/>
<div class="row tooltip-block"><a href="#" data-toggle="popover" data-trigger="hover" data-placement="auto right" data-content="Test tooltip.">
<span class="glyphicon glyphicon-question-sign"></span></a>
</div>
</div>
</div>
In full screen it looks as I need:
But on mobile devices or small screens it works only with hovering some very small area within my glyphicon mark and the tooltip overlays it:
Also when I inspect the corresponding a element in Chrome's developer tools, it points to some area outside the span element:
Here is the fiddle: https://jsfiddle.net/r2cm9c9u/
How is it possible to make the whole span with glyphicon as a hyperlink for tooltip?

I would move the positioning to the actual link and make the link and glyphicon a block element:
I have added a class to the link below
<div class="form-group required">
<label for="username" class="col-sm-2 control-label">User Name:</label>
<div class="col-sm-3 tooltip-box">
<input id="username" type="text" class="form-control" placeholder="username" />
<div class="row tooltip-block">
<a href="#" data-toggle="popover" data-trigger="hover" data-placement="auto right" data-content="Test tooltip." class="glyphicon-holder">
<span class="glyphicon glyphicon-question-sign"></span></a>
</div>
</div>
</div>
And changed your classes:
.tooltip-box .glyphicon-holder {
position: absolute;
top: 8px;
right: 22px;
font-size: 1.25em;
display: block;
}
.tooltip-box .glyphicon-holder:hover {
text-decoration: none;
}
.glyphicon.glyphicon-question-sign {
color: gray;
display: block;
}
Updated fiddle

You can do it with pure css.
If you have:
<div class="col-sm-3 tooltip-box">
<input id="username" type="text" class="form-control" placeholder="username"/>
<div class="row tooltip-block"><a href="#" data-toggle="popover" data-trigger="hover" data-placement="auto right" data-content="Test tooltip.">
<span class="glyphicon glyphicon-question-sign"></span></a>
</div>
</div>
You don't need 'a' first of all. What you can do with CSS is:
.tooltip-block span {
display: none;
}
.tooltip-block:hover + span {
display: block;
}
Whats gonna happen is, when you hover over .tooltip-block following span element will display block. Definitely don't need javascript for a thing like this.
Then if you want that tooltip to be clickable you can use javascript for that.
<div class="col-sm-3 tooltip-box">
<input id="username" type="text" class="form-control" placeholder="username"/>
<div class="row tooltip-block" onclick="doSomething()"><a href="#" data-toggle="popover" data-trigger="hover" data-placement="auto right" data-content="Test tooltip.">
<span class="glyphicon glyphicon-question-sign"></span></a>
</div>
</div>

Related

How to add margin-top to hyperlink inside bootstrap col/form?

I am trying to beautify a form in bootstrap. I don't understand why I can not add some margin to a hyperlink thats below an input? I tried to remove bootstrap and that didn't work, so I don't think it has something to do with bootstrap!
https://jsfiddle.net/k8ws75je/
<div class="col-md-8 col-md-offset-2">
<form class="form-horizontal" role="form" method="POST" action="{{ route('register') }}">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control" name="name" value="" required autofocus>
<span class="help-block">
<strong></strong>
</span>
</div>
</div>
<div class="form-group">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
</div>
<div>
<div class="col-md-6 col-md-offset-4">
<a id="linkpassword" href="#">Change Password</a>
<button type="submit" class="btn btn-success pull-right">
Update
</button>
</div>
</div>
</form>
#linkpassword{
margin-top: 400px;
}
That's because a elements are inline elements, which cannot have vertical margins. Change it to an inline-block to make it work
#linkpassword{
margin-top: 200px;
display: inline-block;
}
https://jsfiddle.net/knu1badd/1/
#linkpassword{
margin-top: 400px;
position:absolute;
}
Make it display: block. Thus it will be as you want.
warp a element in a div block and apply the position/margin on this block.
Because a is an inline element.
<div class="margin-top">
<a id="linkpassword" href="#">Change Password</a>
</div>

Two-column unordered list - keeping each li's content in one column

Best described by example.
I have two issues that I couldn't solve after hours of researching.
1) Stop HTML separating a single li content. For example, we can see that Group C heading in rendered in the first column, and the rest is rendered in the second.
2) Render the OK button so that it is out of the ul - in the left or right corner of the drop-down room.
<div>
<span style='cursor:pointer; float:right'>
<div class="btn-group pull-right">
<button id = 'majic' type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-cog"></span>
</button>
<ul style='padding:10px; width:auto' class="dropdown-menu zeon-search-settings-dropdwown-menu zeon-two-columns-ul">
<li class="dropdown-submenu zeon-dropdown-submenu">
<div class='section-heading-3'>Group A</div>
<div>
<label class='zeon-input-label'>
<input id="white_agreements_filter" type="checkbox" name="vehicle" checked class='zeon-checkbox' />Choice</label>
</div>
<div>
<label class='zeon-input-label'>
<input id="black_agreements_filter" type="checkbox" name="vehicle" checked class='zeon-checkbox' />Choice</label>
</div>
</li>
<li class="dropdown-submenu zeon-dropdown-submenu">
<div class='section-heading-3'>Group B</div>
<div>
<label class='zeon-input-label'>
<input id="cash_payment_filter" type="checkbox" name="vehicle" checked class='zeon-checkbox' />Choice</label>
</div>
<li class="dropdown-submenu zeon-dropdown-submenu">
<div class='section-heading-3'>Group C</div>
<div class="row">
<div class="col-sm-1">
</div>
<div class="col-sm-7">
<form>
<label class="radio-inline">
<input type="radio" name="optradio">
< </label>
<label class="radio-inline">
<input type="radio" name="optradio">=
</label>
<label class="radio-inline">
<input type="radio" name="optradio">>
</label>
</form>
</div>
<div class="col-sm-4">
<input class="form-control input-sm" id="inputsm" type="text" placeholder='количетсво дней'>
</div>
</div>
</li>
<li class="dropdown-submenu">
<div class='section-heading-3'>Group D</div>
<div>
<label class='zeon-input-label'>
<input id="full_package_filter" type="checkbox" name="vehicle" checked class='zeon-checkbox' />Choice</label>
</div>
<div>
<label class='zeon-input-label'>
<input id="not_full_package_filter" type="checkbox" name="vehicle" checked class='zeon-checkbox' />Choice</label>
</div>
</li>
<li class="dropdown-submenu">
<button id='vendor_list_filter_ok_button' type="button" class="next btn btn-default btn-sm pull-left">ОК</button>
</li>
</ul>
</div>
</span>
</div>
You can use flexbox for that (You can play with the height of the ul.dropdown-menu, if you add more height the group-c block will move to the left column)
This is the added css:
.open>ul.dropdown-menu {
display: flex;
width: 400px !important;
flex-wrap: wrap;
flex-direction: column;
height: 250px;
}
ul.dropdown-menu li {
width: 50%;
}
Here is the working jsfiddle:
https://jsfiddle.net/p6yf17du/
Update
If you don't care (or if you can change the markup) about the order of the elements you can use:
.open>ul.dropdown-menu {
display: flex;
width: 400px !important;
flex-wrap: wrap;
}
This will change the order of your elements from
A | C
B | D
to
A | B
C | D
However, this way you don't need to set the height of the menu (only the width, which makes sense to me).
You can check here:
https://jsfiddle.net/m0rg1uoe/
You can try to solve this issue adding to last <li> element the column-span property. Applying this rule with value all it will force the last <li> element to cover all the columns.
For example see the following code:
HTML:
...
<li class="dropdown-submenu btn-confirm">
<button id='vendor_list_filter_ok_button' type="button" class="next btn btn-default btn-sm pull-left">ОК</button>
</li>
...
CSS:
.btn-confirm {
-webkit-column-span: all;
column-span: all;
}
Once that last element cover both columns, also Group C heading will displayed correctly.
You can find a live demo here.
Attention: column and column-span properties have some issues in different browsers. See caniuse website and check browsers support.
Try This
.zeon-dropdown-submenu {
margin-top: 10px;
min-height: 100px;
}

How do I apply a max-width to an input field form-control with a trailing secondary button in Bootstrap 3?

When I attempt to apply a maximum width to an input field, it positions the secondary button as if the input field didn't have a maximum width.
JSFiddle Example
HTML:
<div class="container">
<div class="form-group">
<label class="control-label">Date</label>
<div class="input-group">
<input type="text" maxlength="10" class="form-control datefield" placeholder="mm/dd/yyyy">
<span class="input-group-btn">
<button id="btnClearDate" class="btn btn-secondary btn-default" type="button">Clear</button>
</span>
</div>
</div>
</div>
CSS:
.datefield {
max-width: 100px;
}
Result:
How can I get the secondary button to correctly sit next to the text field?
Try using display:inline-block;
https://jsfiddle.net/ex3ntia/DTcHh/22030/
.input-group-btn {display:inline-block;}
Bootstrap is laid out by using a grid system. You will need to adjust your design layout to accomplish what you are looking to achieve.
What is happening now is all you are doing is shrinking down the size of the input box, but not the actual grid cell.
try adjusting just the cell or placing the form-group elements within a cell then within a targeting element you can shrink.
Try this,
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
padding: 10px;
}
.shrink {
width: 200px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="form-group">
<div class="shrink">
<label class="control-label">Date</label>
<div class="input-group">
<input type="text" maxlength="10" class="form-control datefield" placeholder="mm/dd/yyyy">
<span class="input-group-btn">
<button id="btnClearDate" class="btn btn-secondary btn-default" type="button">Clear</button>
</span>
</div><!-- .input-group -->
</div><!-- .shrink -->
</div><!-- .form-group -->
</div><!-- .row -->
</div> <!-- .container -->
Hope that helps!
The span was not being displayed inline. I assume this was changed with the input-group-btn class. Here is the new code (I named the new class ):
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
.datefield {
max-width: 100px;
}
.buttoncleardiv {
display: inline;
}
<div class="container">
<div class="form-group">
<label class="control-label">Date</label>
<div class="input-group">
<input type="text" maxlength="10" class="form-control datefield" placeholder="mm/dd/yyyy">
<span class="input-group-btn buttoncleardiv">
<button id="btnClearDate" class="btn btn-secondary btn-default" type="button">Clear</button>
</span>
</div>
</div>
The JS Fiddle is here

.field_with_errors in Rails breaks Twitter Bootstrap 3 input styles with addons

I have HAML
...
.row
.col-md-3.form-group
= offer.label :departure_date, "Abfahrt"
.input-group.date
= offer.text_field :departure_date, class: "form-control", readonly: ""
%span.input-group-addon
%i.glyphicon.glyphicon-calendar
...
that generates such HTML (datepicker markup)
<div class="row">
<div class="col-md-3 form-group">
<label for="offer_departure_date">Abfahrt</label>
<div class="input-group date">
<input class="form-control" readonly="readonly" type="text" name="offer[departure_date]" id="offer_departure_date">
<span class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
</div>
When I get error, Rails wraps label and input with a div having class field_with_errors.
<div class="row">
<div class="col-md-3 form-group">
<div class="field_with_errors"><label for="offer_departure_date">Abfahrt</label></div>
<div class="input-group date">
<div class="field_with_errors"><input class="form-control" readonly="readonly" type="text" value="" name="offer[departure_date]" id="offer_departure_date"></div>
<span class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
</div>
In my application.css.sass I've extended field_with_errors with the following:
.field_with_errors
#extend .has-error
After that most simple fields became normal styling accept of this datepicker: the input field lost its rounded corners, addon part remained default (even not red). In combination with other fields this looks ugly. How can that be fixed? Here is screenshot with this field - http://minus.com/lbeNYx1yXyqk4C
Use the following css to fix the issue
.field_with_errors {
display: block !important;
}
.field_with_errors > .datetimepicker {
display: none !important;
}

Align two input textbox and one button horizontally

I have two inputs, one button and one drop down menu, how do i align it so that its next to each other. I have created div for each element but things dont look right. this is what i have done:
<div class="class1">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
<div class="input1" >
<input type="text" value="" class="form-control" id="deatPicker1">
</div>
<div class="class1" >
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
<div class="input1">
<input type="text" value="" class="form-control" id="deatPicker2">
</div>
<div class="button" style="display: inline-block;">
<button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"> </i></button>
</div>
My Css: during this process i have noticed the above example works fine but only if i create another web-page if i use my current web page then things dont stay the way i want
.class1{
display: inline-block;
width: 15px;
}
.input1{
display: inline-block;
width: 200px;
padding-left: 20px;
}
It looks like you're using bootstrap.
So you can align it all using rows and cols.
like so :
<div class="row class1">
<div class="col-md-4">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i> </span>
<input type="text" value="" class="form-control" id="deatPicker1">
</div>
<div class="col-md-4">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i> </span>
<input type="text" value="" class="form-control" id="deatPicker2">
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-default">
<i class="glyphicon glyphicon-search"></i>Search</button>
</div>
</div>
a row gives you a maximum of 12 cols.. so depending on how many aligned items you want, you can do :
<div class="col-md-3"></div> x 4 to get a 4 col layout
http://jsfiddle.net/mT6VV/7/
Try this Code :-
<div class="class1">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
<div class="input1" >
<input type="text" value="" class="form-control" id="deatPicker1">
</div>
<div class="class1" >
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
<div class="input1">
<input type="text" value="" class="form-control" id="deatPicker2">
</div>
use this Css :
.class1 {
display: inline-block;
}
.input1 {
display: inline-block;
width: 200px;
padding-left: 20px;
}
button {
width:90px;
height:20px;
}
you don't have need to put extradiv tag in your design source.
Demo For Alignment
it is working.

Resources