When stacking icons, how can I center the second icon?
I'm trying to create a white background for a circle and a checkbox see plnkr example:
http://plnkr.co/5JM1yk6eoeAnj1VgkxXA
<span class="fa-stack">
<i class="fa fa-circle-thin fa-stack-2x"></i>
<i class="fa fa-check-circle fa-stack-2x"></i>
</span>
input[type="checkbox"]:checked + label .fa-check-circle {
display: block;
background: white;
border-radius: 50%;
color: #37B34A;
height: 28px;
width: 28px;
}
.fa-circle-thin {
color: #DDDDDD;
background-color: #FFFFFF;
border-radius: 50%;
height: 28px;
width: 28px;
text-align:center;
cursor: pointer;
}
Giving a margin-left to .fa-stack .fa-check-circle will do it
.fa-stack .fa-check-circle {
margin-left: 2px;
}
Although I think this is not the best way of doing what you're trying to do there, I think this way should be a better way of doing it: http://jsfiddle.net/7w41fboo/
======== Update =========
If you need to remove the white space of the background of your checked circle, you can do it with this trick. First exchange the fa-check-circle for fa-check like this:
HTML
<div class="faWhiteBg">
<input type="checkbox">
<label>
<span class="fa-stack">
<i class="fa fa-circle-thin fa-stack-2x"></i>
</span>
Unchecked
</label>
</div>
<br />
<input type="checkbox" checked>
<label>
<span class="fa-stack">
<i class="fa fa-check"></i>
</span>
Checked
</label>
Then style your fa-check in your CSS
.fa-stack .fa-check {
background: #37B34A;
color: #fff;
font-size: 22px;
padding: 5px;
border-radius: 50%;
}
.fa-stack {
cursor: pointer;
}
/* The code below is a code to display the white background only for the non checked circle, if you don't want it you can remove this part of the code and remove it from your HTML as well*/
.faWhiteBg .fa-stack {
background: #fff;
border-radius: 50%;
}
Here's an online example
Related
I've got an icon 'X' that shows in corner of button when button is hovered. Problem is I can't click on it for some reason, like element doesnt even exist. Here is html:
<button *ngIf="favapps.indexOf('qualitydocs') >= 0" (mouseover)="showQualitydocs = true" (mouseleave)="showQualitydocs = false" class="btn btn-sq btn-primary text-center"
[routerLink]="['/dokumenti-kvalitete']">
<i class="fa fa-file-text-o inside fa-2x" aria-hidden="true"></i>
<br>Dokumenti
<br> kvalitete
<span class="relative-qualitydocs"><span class="absolute-qualitydocs" *ngIf="showQualitydocs" (mouseover)="showQualitydocs = true" (mouseleave)="showQualitydocs = false"><i class="fa fa-close"></i></span></span>
</button>
and css:
.absolute-qualitydocs {
z-index: 100;
position: absolute;
top: 22px;
background: #fff;
border: 1px solid #67809F;
padding: 0 3px;
cursor: pointer;
color: #67809F;
&:hover {
background-color: #d1d1d1;
}
}
.relative-qualitydocs {
position: relative;
cursor: pointer;
left: -67px;
top: -67px
}
As you can see on the picture it shows correctly, but I cant click on it, I cant hover it, even cursor: pointer doesn't work. Any ideas what might be wrong? Tried putting z-index and display: block, didn't help.
Screenshot:
Try this HTML and CSS
.delete-hover {
z-index: 100;
background: #fff;
border: 1px solid #67809F;
padding: 0 3px;
cursor: pointer;
color: #67809F;
}
.delete-hover:hover {
background-color: #d1d1d1;
}
.relative-qualitydocs {
position: relative;
cursor: pointer;
}
.absolute-qualitydocs {
position: absolute;
top: 0;
left: -18px;
}
<button class="btn btn-sq btn-primary text-center relative-qualitydocs">
<i class="fa fa-file-text-o inside fa-2x" aria-hidden="true"></i>
<br>Dokumenti
<br> kvalitete
<span class="delete-hover absolute-qualitydocs" *ngIf="showQualitydocs" (mouseover)="showQualitydocs = true" (mouseleave)="showQualitydocs = false">×</span>
</button>
Fixed it by putting 'span' ('div' also works) as a parent element instead of 'button' ... if anyone has a clue why this happens, please share cause i have no clue... here is working pen
<button class="parent-relative"> <!-- doesnt work -->
<span class="child-absolute"></span>
</button>
<span class="parent-relative"> <!-- works -->
<span class="child-absolute"></span>
</span>
css:
.parent-relative {
position:relative;
padding: 200px;
background: red;
margin:50px;
}
.child-absolute {
position:absolute;
padding:20px;
background:yellow;
cursor:pointer;
top: 0;
left:-40px;
}
I had upgraded my rating plugin with font awesome icons instead of images. I am facing problem on half star rated which I can't replace white color on the fa-star-half-o icon. I would like to replace the white color with grey color similar to expected result below.
Please help
Code :
<div class="ratingbox"><i class="fa fa-star"></i><i class="fa fa-star">
</i><i class="fa fa-star-half-o"></i><i class="fa fa-star unrated"></i>
<i class="fa fa-star enlang unrated"></i></div>
i
{
float:left
}
.ratingbox
{
display: block;
clear: both;
}
.fa-star-half-o,.fa-star
{
color: #ffab00;
}
.rated{
color: #ffab00;
cursor: pointer;
}
.unrated{
color: #757575;
cursor: pointer;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="ratingbox">
<i class="fa fa-star"></i><i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i><i class="fa fa-star unrated"></i><i class="fa fa-star enlang unrated"></i>
</div>
Current Result
Expected Result
Everything is possible in web design but maybe you manage to use some trick:
i
{
float:left;
position: relative;
}
.ratingbox
{
display: block;
clear: both;
}
.fa-star-half-o,.fa-star
{
color: #ffab00;
}
.rated{
color: #ffab00;
cursor: pointer;
}
.unrated{
color: #757575;
cursor: pointer;
}
.fa-star-half-empty:after, .fa-star-half-full:after, .fa-star-half-o:after {
content: "\f123";
transform: rotateY(-180deg);
display: inline-block;
left: 6px;
position: absolute;
top: 0;
color: #757575;
overflow: hidden;
width: 8px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="ratingbox">
<i class="fa fa-star"></i><i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i><i class="fa fa-star unrated"></i><i class="fa fa-star enlang unrated"></i>
</div>
Note: I just add fa-star-half-o character to after element, i mean this content: "\f123"; then reverse it transform: rotateY(-180deg); and half width and absolute position you can see what's happened here:
.fa-star-half-empty:after, .fa-star-half-full:after, .fa-star-half-o:after {
content: "\f123";
transform: rotateY(-180deg);
display: inline-block;
left: 6px;
position: absolute;
top: 0;
color: #757575;
overflow: hidden;
width: 8px;
}
It's not clean but better than nothing!
You can use CSS ::before and ::after pseudo-elements refer here for CSS unicodes.
Add an extra .unrated star
Add 2 pseudo-elements to the half-o ; ::before and ::after
Make sure that the pseudo-elements are absolute and the half-o is relative.
And to cleanly fill the rightside of half star, explicitly set the ::before pseudo-element to color:grey.
Demo
i {
float: left;
}
.ratingbox {
display: block;
clear: both;
}
.fa-star-half-o,
.fa-star {
color: #ffab00;
}
.rated {
color: #ffab00;
cursor: pointer;
}
.unrated {
color: #757575;
cursor: pointer;
}
.fa-star-half-o {
position: relative;
}
.fa-star-half-o:after {
font-family: FontAwesome;
content: '\f089';
position: absolute;
z-index: 1;
}
.fa-star-half-o:before {
font-family: FontAwesome;
content: '\f089';
position: absolute;
color: grey;
z-index: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="ratingbox">
<i class="fa fa-star"></i><i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i><i class="fa fa-star unrated"></i><i class="fa fa-star unrated"></i><i class="fa fa-star unrated"></i>
</div>
I am trying to make a search field with a dropdown inside. I have been trying to use bootstrap's input group to give the illusion that the button is inside the field.
This is what I am trying to accomplish in the screenshot below:
This is what I have so far:
I am trying to figure out how to get the dropdown menu to move over to the far right of the search field and get that carrot to show as well.
Any tips on adjusting the position of the menu as well as making that dropdown button have no color on hover?
<div class="container div-cntr">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control input-lg" id="toolSearch" name="toolSearch" placeholder="What are you looking for?">
<div class="input-group-btn">
<button aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" class="btn btn-default btn-lg dropdown-toggle filterOptions" type="button"> <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span> </button>
<ul class="dropdown-menu">
<li><input type="checkbox"/> Option 1</li>
<li><input type="checkbox"/> Option 2</li>
</ul>
</div>
</div>
<br />
<button type="button" class="btn btn-default btn-lg">Search</button>
</div>
</div>
-
.div-cntr {
left: 50%;
margin-left: -350px;
margin-top: -150px;
min-height: 150px;
position: absolute;
text-align: center;
top: 50%;
width: 700px;
}
.filterOptions{
border-left: 0px;
}
.btn-lg {
line-height: 1.22;
}
#toolSearch:focus {
outline:none;
}
Here is a fiddle I have set up: https://jsfiddle.net/carlhussey/tfrpncu7/
Here is the CSS you need to accomplish what you indicated you wanted:
.dropdown-menu {
right: 0; /* Align dropdown-menu to right instead of left */
left: auto;
}
.input-group .dropdown-toggle.filterOptions {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
z-index: 5; /* Fix for 2 input-group-btns and this one not being the last-child */
}
.dropdown-menu>li>a:focus,
.dropdown-menu>li>a:hover {
background-color: transparent; /* Fix for dropdown-menu item hover background-color */
}
Here is what it looks like:
I went ahead and updated your Fiddle:
https://jsfiddle.net/tfrpncu7/3/
You should be using input-group-lg along with input-group and dropdown-menu-right to position the dropdown menu correctly. For the other CSS use pseudo elements.
Working Example: (The level of specificity is so the example works on Stackoverflow.)
.div-cntr {
margin-top: 100px;
text-align: center;
max-width: 700px;
/*for example only*/
background: red;
min-height: 300px;
/*for example only*/
}
.form .open>.dropdown-toggle.filterOptions.focus,
.form .open>.dropdown-toggle.filterOptions:focus,
.form .open>.dropdown-toggle.filterOptions:hover .input-group-lg>.form-control,
.form .input-group.input-group-lg>.input-group-btn>.filterOptions {
border: 1px solid #ccc;
border-left: 0;
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border-radius: 0;
background: #fff;
}
.form .dropdown-menu.dropdown-menu-search {
top: 60px;
right: 110px;
border-radius: 0;
border: 0;
background: #fff;
}
.form .dropdown-menu.dropdown-menu-search:after {
top: -15px;
right: 10px;
position: absolute;
content: '';
border-width: 0px 15px 15px 15px;
border-style: solid;
border-color: #fff transparent;
height: 0;
width: 0;
}
.form .form-control.toolSearch,
.form .form-control.toolSearch:focus {
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border-radius: 0;
border: 1px solid #ccc;
border-right: 0;
}
.form .input-group-btn .btn.btn-search,
.form .input-group-btn .btn.btn-search.active {
border-radius: 0;
border: 1px solid #ccc;
border-left: 0;
}
.form .input-group-btn .btn.btn-search:hover,
.form .input-group-btn .btn-search:focus {
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border: 1px solid #ccc;
border-left: 0;
border-radius: 0;
background: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container div-cntr">
<div class="form-group form">
<div class="input-group input-group-lg">
<input type="text" class="form-control toolSearch" id="toolSearch" name="toolSearch" placeholder="What are you looking for?">
<div class="input-group-btn">
<button aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" class="btn btn-default btn-lg dropdown-toggle filterOptions" type="button"> <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu dropdown-menu-right dropdown-menu-search">
<li>
<a href="#" class="small" data-value="option1" tabIndex="-1">
<input type="checkbox" /> Option 1</a>
</li>
<li>
<a href="#" class="small" data-value="option2" tabIndex="-1">
<input type="checkbox" /> Option 2</a>
</li>
<li>
<a href="#" class="small" data-value="option3" tabIndex="-1">
<input type="checkbox" /> Option 3</a>
</li>
<li>
<a href="#" class="small" data-value="option4" tabIndex="-1">
<input type="checkbox" /> Option 4</a>
</li>
<li>
<a href="#" class="small" data-value="option5" tabIndex="-1">
<input type="checkbox" /> Option 5</a>
</li>
<li>
<a href="#" class="small" data-value="option6" tabIndex="-1">
<input type="checkbox" /> Option 6</a>
</li>
</ul>
<button role="button" class="btn btn-lg btn-default btn-search"><span class="glyphicon glyphicon-search"></span> Search</button>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
Here's a Fiddle with the position of the dropdown set, and the button with a white background on `:active'. Let me know if this is what you were looking for.
https://jsfiddle.net/tobyl/4p41p3kg/2/
Added CSS:
.dropdown-menu {
left: auto;
right: 0;
}
.open > .dropdown-toggle.btn-default:active, .open > .dropdown-toggle.btn-default:focus {
background-color: #fff;
}
I'll start by answering the second part of your question
Making that dropdown button have no color on hover
Chrome dev-tools (right click any element of the page and select Inspect element) can help a lot when it comes to styling elements under certain states (like hover). To see which style rule is applied during hover we can force the hover state on the button through dev-tools. We see that .btn-default is applying
.btn-default:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
}
Since this button has the following class precedence
<button class="btn btn-default btn-lg dropdown-toggle filterOptions"> (classes to the right override rules from classes to the left)
We can override the hover styles of .btn-default by making a rule for the hover state of filterOptions.
.filterOptions:hover {
background-color: white;
border-color: #ccc;
}
Adjusting the position of the menu as well as
Again by inspecting the dropdown element in dev-tools we can see that the correct style rule to override the default positioning and make the dropdown position to the right would be:
.open>.dropdown-menu {
right: 0;
left: initial;
}
Updated fiddle:
https://jsfiddle.net/tfrpncu7/4/
Remember, css has no scoping what so ever so it's a good idea to always apply new non-bootstrap classes when styling a specific element.
If your project is large, consider using a css naming convention like BEM to keep the risk of naming collisions low.
In the footer for this page http://128.199.58.229/landingpage/
I have some Font Awesome icons (social media icons).
I'm trying to give them a white background just behind the icons themselves. The white background currently sticks out. I've read some posts on using a combination of width, height and border radius to achieve this, but currently no success.
.lt-bus-info .fa {
background-color: white;
border-radius: 50%;
}
Here's a jsfiddle: http://jsfiddle.net/magician11/nfz9sucn/1/
I'm looking for just the white behind the symbol: https://dl.dropboxusercontent.com/u/14057353/Screen%20Shot%202014-12-03%20at%204.01.18%20pm.png
Anyone know how to fix this?
Thanks.
Use stacked icons instead . Here is a fiddle, you can play with it to make it far more better. Below is full code :
HTML
<ul class="list-inline">
<li><a href="#">
<span class="fa-stack fa-lg icon-facebook">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x"></i>
</span>
</a></li>
<li><a href="#">
<span class="fa-stack fa-lg icon-twitter">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
</a></li>
<li><a href="#">
<span class="fa-stack fa-lg icon-gplus">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-plus fa-stack-1x"></i>
</span>
</a></li>
</ul>
CSS
.fa-stack-1x {
color:white;
}
.icon-facebook {
color:#3b5998;
}
.icon-twitter {
color:#00aced;
}
.icon-gplus{
color:#dd4b39;
}
body {
background-color: black;
}
I'm surprised no one has mentioned this approach yet:
html
<div class="social-media text-right">
<a href="" class="facebook">
<span class="fa fa-facebook"></span>
</a>
</div>
css
.social-media a
{
display: inline-block;
width: 34px;
height: 34px;
line-height: 34px;
text-align: center;
margin-right: 10px;
border-radius: 34px;
}
.social-media a.facebook
{
background: #3b5998;
}
I Was searching for the solution but didn't found perfect one with less code so I spend little time and made this fiddle for you.
HTML
<div class="background">
<i class="fa fa-facebook-square fb-btn"></i>
<i class="fa fa-twitter-square twt-btn"></i>
<i class="fa fa-google-plus-square gp-btn"></i>
</div>
CSS
.fb-btn{
background-color: #fff;
border-radius: 50% 8px 10px 50%;
color: #305891;
font-size: 40px;
height: 32px;
line-height: 30px;width: 32px;
margin: 5px;
}
.twt-btn{
background-color: #fff;
border-radius: 50%;
color: #2ca8d2;
font-size: 40px;
height: 30px;
line-height: 30px;
margin: 5px;
width: 30px;
}
.gp-btn{
background-color: #fff;
border-radius: 50%;
color: #dd4b39;
font-size: 40px;
height: 30px;
line-height: 30px;
width: 30px;
margin: 5px;
}
.background{
background-color:#cccccc;
width:150px;
height:60px;
padding:60px 50px;
}
You may need to play with some border radius, line-height and margins but that's good fit and faster solution I believe.
Let me know if there's any mistake!
Here is a really cool way to do it that has not been mentioned here and in a couple lines of code you're gtg.
i.fa-smile-o {
position: relative;
color: #555;
}
i.fa-smile-o:before {
content: "\f111";
color: #f1c40f;
}
i.fa-smile-o:after {
left: 0;
top: 0;
position: absolute;
content: "\f118";
}
This way you can also fill the content with meh or frown codes that can be found here, enjoy!
The easiest will probably to give the list item a background color like so
li {
background-color: white;
}
background-image: linear-gradient( to bottom, transparent 20%, white 20%, white 93%, transparent 93% );
background-size: 84%;
background-position: 60% 0;
background-repeat: no-repeat;
See examples
I am trying to convert xixilive's jQuery Spinner Plugin that uses Bootstrap 2.3.2 code into bootstrap 3.* Unfortunately it's not working as it should be, along with no JavaScript errors, so I believe it's just a CSS issue.
Here is what I have done so far:
HTML/CSS
<div class="input-group spinner" data-trigger="spinner">
<input type="text" value="0"
data-min="0"
data-max="10"
name="spinner"
id="spinner"
data-rule="quantity" readonly />
<span class="input-group-btn">
<!-- Up arrow -->
<a href="javascript:;" class="spin-up" data-spin="up">
<i class="fa fa-sort-up"></i>
</a>
<!-- Down arrow -->
<a href="javascript:;" class="spin-down" data-spin="down">
<i class="fa fa-sort-down"></i>
</a>
</span>
</div>
Expected output
Demo Fiddle: http://jsfiddle.net/DAS3K/
I just solved it by myself. Here is the code if anyone is looking for solution
Replace bootstrap-spinner.css file with this one:
.spinner .input-group-btn {
padding: 2px
}
.spinner .input-group-btn a.spin-up, .spinner .input-group-btn a.spin-down {
height: 10px;
overflow: hidden;
display: block;
text-align: center;
position: relative;
color: #999
}
.spinner .input-group-btn a.spin-up .fa-sort-down, .spinner .input-group-btn a.spin-down .fa-sort-down {
position: relative;
top: -9px
}
.spinner .input-group-btn a.spin-up:hover, .spinner .input-group-btn a.spin-down:hover {
color: #555
}
.spinner input {
width: 4em;
text-align: center;
font-size: 12px;
border-radius: 4px 0 0 4px;
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
line-height: 20px;
}
.spinner .input-group-btn {
background-color: #EEEEEE;
border: 1px solid #CCCCCC;
height: 20px;
line-height: 20px;
min-width: 14px;
padding: 4px 5px;
text-align: center;
text-shadow: 0 1px 0 #FFFFFF;
width: auto;
}
.spinner .input-group-btn a:focus {color: #999 !important; }
and use following HTML code
<div class="col-sm-1">
<div class="input-group spinner" data-trigger="spinner">
<input type="text" class="form-control" value="0" data-min="0" data-max="10" name="spinner" id="spinner" data-rule="quantity" >
<span class="input-group-btn">
<i class="fa fa-sort-desc"></i>
<i class="fa fa-sort-down"></i>
</span>
</div>
</div>
If you use to want use glyphicon instead of font-awesome then replace fa and fa-xxx classes in HTML and bootstrap.spinner.css file as well.
You could:
Wrap the buttons into a bootstrap add-on
Switch icon to glyphicon for the icon spinners, there's no direct suitable change though for the old to new icons thus I've adjusted for chevrons.
Swap input-group-btn to input-group-addon
This would produce HTML a little like:
<div class="input-append spinner" data-trigger="spinner">
<div class="input-group">
<input type="text" id="spinner-input" class="form-control" value="1" data-rule="quantity" />
<span class="input-group-addon">
<i class="glyphicon glyphicon-chevron-up"></i>
<br />
<i class="glyphicon glyphicon-chevron-down"></i>
</span>
</div>
</div>
I've had apply some extra CSS rules and the linebreak for the buttons could be handled instead with mini columns instead! but I hope that gives you an head-start regardless!
Result:
Demo Fiddle: http://jsfiddle.net/792hq/