i have to set of buttons one have no icon and one have icons. i want to define a special css which has no icon..
My codes are
for first type of button:-
<div class="btn-double-horizontal">
<button type="button" class="btn btn-lg btn-base-white border-base thin">register now</button>
<span>or</span>
<button type="button" class="btn btn-lg btn-base-white border-base thin">login here</button>
</div>
and for second type (with icon):-
<div class="btn-double-horizontal">
<button type="button" class="btn white rounded bg-wisteria btn-lg"><i class="fa fa-instagram white bullet"></i>Instagram</button>
<span>or</span>
<button type="button" class="btn white rounded bg-green-sea btn-lg"><i class="fa fa-linkedin white bullet"></i>Linked in</button>
i want to apply style for buttons which has no icon.Obviously they are both btn-lg (class)
If I'm understanding this correctly, you want to target the first type of button you laid out in your question, correct?
If so, since the two button types don't share all the same classes, you could do something like this:
.btn.btn-base-white {
/* This targets the first type of button only */
}
This doesn't require the use of the :not() selector, which really is only an issue in IE8, but I don't know what browsers you need to support, so better safe than sorry.
Of course, this assumes you can't add another class. If you can add a new class to the buttons without an icon, that may make your CSS easier to work with down the road...
In your examples, .btn-lg:not(.btn-base-white){...} would do the trick, if you want to use :not()
If you are trying to apply the special CSS to all buttons that do not contain an icon, you will have to add an icon class to buttons that contain an icon. Then use can target them with button:not(.icon). You can not look for buttons that do not contain an icon in CSS because there is no parent selector
Example:
.button{
/* button css */
}
.button:not(.icon){
/* button with no icon css */
color: #f00;
}
<button class="button icon">icon</button>
<button class="button">no icon</button
1) The best way to do this is to make 2 custom classes:
First: With the icons (.with-icon)
.with-icon{//code for iconed button goes here. }
Second: Without icons (.no-icon)
.no-icon{//code for non-iconed button goes here. }
And, then do the required changes based on the 2 classes for your both item types.
2) For your present case scenario, you might make use of the classes that are already in your 2 types of buttons, viz.
.btn-base-white {//code for non-icon button goes here }
.bg-wisteria {//code for iconed button goes here }
3) If you still want to use .not then go as follows:
button:not(.btn-base-white ) {//code for iconed button goes here}
button:not(.bg-wisteria) {//code for non-iconed goes here}
Hope, that helps!
Related
NOTE: I am using Angular, so if Angular can solve this it will also work
I want to build a page where I can view the styles I am making. Therefore I need to somehow activate the hover and active states. Here is my code now:
.myclass {
background-color: blue
}
.myclass:disabled {
background-color: red
}
.myclass:hover {
background-color: green
}
.myclass:active {
background-color: pink
}
<button class="myclass" disabled="true">Disabled</button>
<button class="myclass">Normal</button>
<button class="myclass">Hover</button>
<button class="myclass">Active</button>
I am hoping for something like this:
<button class="myclass" disabled="true">Disabled</button>
<button class="myclass">Normal</button>
<button class="myclass hover">Hover</button>
<button class="myclass active">Active</button>
Or:
<button class="myclass" disabled="true">Disabled</button>
<button class="myclass">Normal</button>
<button class="myclass" hover="true">Hover</button>
<button class="myclass" active="true">Active</button>
This can be done easily, just right click on the element -> inspect element -> navigate to the class (myClass in your case) in styles tab.
Then click on :hov and activate the hover, focus or active (refer to the image attached)
If this is for testing purposes use a dedicated hover en active class.
Give the buttons some dummy classes and style the buttons
When you are finished copy the style to the :hover and :active state
and delete the dummy code.
There is no other solution. If there is one than I also want to know what that solution is.
The answer of Divesh Panwar is the way to go.
For development:
Just introduce a new css class that does what you need.
just do
myclass.hover in css then <button class="myclass hover" disabled="true">Disabled</button> and switch back to :hover when finished styling or whatever.
If you use chrome f.E. you can press F12 to open developer console.
There you can toggle the hover state in the top right.
There
For testing:
If it's for some kind of automated tests, and you realy need the hover state, i gues you approach the problem from the wrong side, use a selenium or similar to guide you in the right direction.
Hi guys this might be a simple questions but cant seem to figure it out in bootstrap i have a simple button :
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#myModal">Kontakta oss</button>
I have edited in CSS etc but when its clicked it has a huge blue border around it and the color goes to orange when clicked.
I would like it so that the color stays the same which is black right now and that the border does not change color at all , i just am not sure what the class names are for this
So its not the :Hover class its the click class but again no idea whats it called or the visit something
Thanks
EDIT:
You can see the first button is what it looks like, but when it is clicked on , for a few seconds it changes to orange and then back to black , i want to have it not changed color when the user clicks on it
This is a Bootstrap-specific issue, as you are using a Bootstrap class that stylizes buttons. To override it use this:
.btn-warning.active, .btn-warning:active, .open > .dropdown-toggle.btn-warning {
/* STYLES GO HERE */
color:white!important;
background-color:black!important;
border-color:white!important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#myModal">Kontakta oss</button>
NOTE: In my example code I am using !important to override the default Bootstrap styling because of the way SO loads snippet CSS. This is bad practice and not necessary as long as you load these overrides after the Bootstrap CSS has been loaded.
I am developing an MVC6 project in Visual Studio 2015. I have just added Bootstrap 3.3.6 using Bower. On a very simple html page I have referenced the CSS in the header and Bootstrap at the bottom of the body as follows:
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<script type="text/javascript" src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
I defined a button as follows:
<button class="btn btn-primary">Hello</button>
When I debug the project (IIS, IE11) the button appears and is clearly styled by Bootstrap but there is no hand cursor.
If I use the browser to navigate to an example of a Bootstrap styled button, for example here: http://www.w3schools.com/bootstrap/bootstrap_buttons.asp, the hand cursor appears as I would expect. So it's not my browser at fault.
Can anyone suggest why I am not getting a hand cursor from a simple Bootstrap styled button please?
Try add role='button' instead. I have had this problem even though the documentation on bootstrap says type='button' should do the work but mine didn't.
You need to get rid of the button tags and just use anchor tags with bootstrap classes. For example:
instead of:
<button class="btn btn-primary">Hello </button>
write:
Hello
This will make the HAND CURSOR appear when hovering over the btn bootstrap class
Try adding an href such as href="#" to the button.
<button class="btn btn-primary" href="#">Hello</button>
When you start changing native element types and roles there are other side effects, including how those elements interact with accessibility for users. See this MDN link for details on that: Button Role
You are missing the type="button".
In bootstrap source less file there are several css rules specified for the input[type="button"] rule. (Checked for version 3.3.6)
You might not have to use it, but it was intended to be used with type="button".
In both W3School and Bootstrap buttons demo page they are using type="button"
Your code:
<button class="btn btn-primary">Hello</button>
W3:
<button type="button" class="btn btn-default">Default</button>
If it is still not working after adding type="button" (or submit or reset), try looking on your element with inspector and see what overrides the "pointer: cursor" css rule.
I was looking like you for a way to add this hand over,
until I saw that hand appearing once the form was filled.
(was using
<button type="button" >
by the way )
Create new css:
.cursor-pointer { cursor: pointer; }
Apply css on button:
class="cursor-pointer"
I encountered the same issue. When hover over the button hand cursor is not shown instead mouse pointer is seen. Fixed it by using the following ways.
1st Fix:
<input type="button" id="myBtn" class="btn btn-primary" value="Hello">
2nd Fix:
<a role="button" class="btn btn-primary" href="#">Hello</a>
I have code that's loosely based on the CSS of Bootstrap. One thing I did different is I placed the .btn class inside a button. However it seems like there are many times when the spacing is different and I cannot work out why.
Can anyone give me some advice here. Is it a nono to place the .btn inside a <button> element instead of a <div> when I am using all of the standard CSS for bootstrap?
My guess is that it permits to visually customize more your element when using a div (or an a tag) than when using a button tag since button tag has more associated attributes.
You are likely not wrapping the buttons with a <div> with the .btn-group class.
For example:
<div class="btn-group">
<button class="btn btn-default">Default</button>
<button class="btn btn-primary">Primary</button>
<button class="btn btn-danger">Danger</button>
</div>
There are many additional class modifiers you can add. Check out the component button-group documentation.
Times where you may not use the <button> element would be if you have <a> acting as a button in a <ul>, or in an HTTP Form where you'd want the <input> element to be the button.
On my site 33hotels.com I am using Buttons, such as provided by Twitter Bootstrap, to indicate hotels' amenities.
What I need is to clearly display that an amenity is absent.
For this, I am already displaying the button in red with text crossed by horizontal line. However, from user testing feedback, this is not enough to deliver the message that the amenity is absent. So I need something more clear.
I am thinking of putting a Large cross (letter 'X' or an icon) on top of the button, of the size of the button. The cross should be thin as not to obscure the text but still clearly visible.
My questions are:
How do you put an 'X' on top of a button?
Any elegant and re-usable way to do it?
Maybe define a web component or Angular directive "crossed" that can be attached to an HTML Element?
EDIT. Made my question more clear - I need to put a large X of the size of the button.
EDIT 2: Here is the ugly version of what I'm trying to achieve. However, apart from being ugly, it fails to make the text crossed readable. So perhaps I should use a thinner version of 'X'?
EDIT 3: Here is as good as I could get, not too pretty :(
http://cl.ly/image/1H1p0n2V2200
This is How you do it >> Close button
html
<button class="btn btn-default">End Tour<div class="closebox">X</div>
css
button {
position:relative;
}
.closebox {
position:absolute;
opacity:0.5;
top:-30px;
right:0;
left:0;
font-size:5em;
}
In your case, following code will work for you
<div class="btn push ng-binding btn-default"
ng-class="feature.selected ? 'btn-primary': 'btn-default'"
ng-mousedown="toggleFeature(feature, category, $event)"
ng-bind="feature.name">
<span style="position: relative;top: -9px;float: right;right: -9px;">×</span>
Courtyard
</div>
you can do it using css dynamic content via content:"X" and placing the style on your button element utilizing pseudo-elements for placing the content....
my example is entirely too specific with sizes and positioning: i just wanted to show you how you could do it:
http://jsbin.com/hijaw/1/
Maybe you can use font-awesome or glyphicon to represent when an amenity is absent or not (ok or cross icon + amenity name). Very easy to use and you will avoid to use images or dirty CSS. check Bootstrap 3 examples in:
http://fortawesome.github.io/Font-Awesome/examples/
with bootstrap 3, you can do something like below
<button type="button" class="close">Close
<span aria-hidden="true" style="font-size: 20px">×</span>
</button>
EDIT
another example with font-aswesome
<button class="btn btn-default btn-sm" >
<i class="fa fa-times"></i> Settings
</button>
EDIT 2
to change the size
<button class="btn btn-default btn-sm" >
<i class="fa fa-times" style="font-size: 1em"></i> Settings
</button>
you can increase font size using style on tag