I have looked at the other questions about this and none of the solutions work. I have a vertical navBar that is supposed to hold buttons, which are also links, and they work fine when they are the default width but when I change the size all the buttons overlap and the only one that shows up is the last one.
Relevant CSS code:
.navBar{
background-color: #180639;
width: 20%;
color: #B6AFC1;
text-align: center;
border: 1px solid #B6AFC1;
font-family: Century Gothic, sans-serif;
font-size: 40px;
left: 0px;
position: absolute;
overflow: visible;
}
button.navBar{
font-size: 40px;
background-color: #675AFD;
margin: 10px;
padding: 10px;
display: inline-block;
float: left;
}
Relevant HTML:
<div class="navBar">
<button type="button" class="navBar">Home</button>
<button type="button" class="navBar">Community</button>
<button type="button" class="navBar">Events</button>
<button type="button" class="navBar" class="navBar">Pride Prom</button>
<button type="button" class="navBar">Resources</button>
<button type="button" class="navBar">Fundraising</button>
<button type="button" class="navBar">current_user.username</button>
<a rel="nofollow" data-method="delete" href="/users/sign_out"><button type="button" class="navBar" class="navBar">Log Out</button></a>
</div>
I am writing this using Ruby on Rails if that helps anyone come up with a solution. Sorry if the code is messy, I have been looking at a lot of solutions and adding a bunch of random stuff in just trying to force it to work. I should also note the end goal is for all the buttons to line up in a column
This is what it looks like presently
I think what's causing the problem here is that you are applying the position:absolute property to both the navbar <div> and the <button>s. You should separate the classes to apply separate styling to each, independently:
HTML: (note that I changed the classnames for the <button>s to navBar_button
<div class="navBar">
<button type="button" class="navBar_button">Home</button>
<button type="button" class="navBar_button">Community</button>
<button type="button" class="navBar_button">Events</button>
<button type="button" class="navBar_button">Pride Prom</button>
<button type="button" class="navBar_button">Resources</button>
<button type="button" class="navBar_button">Fundraising</button>
<button type="button" class="navBar_button">current_user.username</button>
<a rel="nofollow" data-method="delete" href="/users/sign_out"><button type="button" class="navBar_button" class="navBar">Log Out</button></a>
</div>
And CSS:
.navBar {
background-color: #180639;
width: 20%;
color: #B6AFC1;
text-align: center;
border: 1px solid #B6AFC1;
font-family: Century Gothic, sans-serif;
font-size: 40px;
left: 0px;
position: absolute;
overflow: visible;
}
.navBar_button {
font-size: 40px;
background-color: #675AFD;
margin: 10px;
padding: 10px;
display: inline-block;
}
Also keep in mind that you don't need the float:left if you have the display:inline-block for the buttons, you can use one or the other. And your navBar div is only 20% width, so these elements will essentially stack on top of each other. If you expand that width to 100%, they will then be next to each other along the top.
Related
I've been struggling for a correct alignemt between two icons and a small text but I cant manage to properly align them:
I need the text to be align with both icons, can someone give me a help; i've checked a very similar post but I couldn't make it work.
.icon-company-title {
margin-top: 30px;
}
.material-icons.md-18 {
color: $primary;
font-size: 40px;
line-height: 0!important;
}
.material-icons.edit {
color: $primary;
vertical-align: middle;
}
.business-icon {
display: inline-block;
vertical-align: bottom;
}
<div class="icon-company-title">
<div class="business-icon">
<i class="material-icons md-18">business</i>
</div>
<span class="company-card-title">{{ entity.name }}</span>
<button class="" mat-icon-button [matMenuTriggerFor]="menu">
<i class="material-icons edit">mode_edit</i>
</button>
</div>
I am using the Google Material Design Lite CSS library (https://getmdl.io/components/#buttons-section) and I can't seem to change the button size even with inline style.
This is the button I am trying to use:
<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect">
<i class="material-icons">add</i>
</button>
I tried added inline code like this but it's not working:
<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect" style="width: 40px; height: 40px"">
<i class="material-icons">add</i>
</button>
Anyone has any idea how to change the button size in MDL?
The .mdl-button and .mdl-button--fab classes both have min-width styles, which is why your width of 40px isn't working. You just have to override the min-width style. This code will work:
<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect" style="width: 40px; height: 40px; min-width: initial;">
<i class="material-icons">add</i>
</button>
Of course it's better to separate your styles, like so:
#myButton {
width: 40px;
height: 40px;
min-width: initial;
}
<!-- Load the MDL stylesheet -->
<link href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css" rel="stylesheet"/>
<button id="myButton" class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect">
<i class="material-icons">add</i>
</button>
This works for me.
button.my-button {
width: 47px;
height: 30px;
min-width: initial;
padding: 0px 0px; //give me more space
font-size: 13px;
line-height: 0px; //make text middle vertically
}
I'm writing a "responsive design" layout and it's been kind of a headache so far. I decided to use the :before and vertical-align: middle; workaround to vertically align some text inside 'buttons', and it works on everything, except one button! The thing is, on refresh, Chrome Mobile will sometimes render it correctly, and sometimes it won't; it seems arbitrary, I haven't been able to find a pattern.
Here's how it should not look:
Here's how it should look:
Here's the relevant markup:
<div class="button">
<a href="/login">
<span class='button-container'>
<span class="button-icon">
<i class="fa fa-sign-in"></i>
</span><br/>
<span class="button-label">
Log In
</span>
</span>
</a>
</div>
<div class="button">
<a href="/signup">
<span class='button-container'>
<span class="button-icon">
<i class="fa fa-user-plus"></i>
</span><br/>
<span class="button-label">
Join Us!
</span>
</span>
</a>
</div>
And the CSS:
.button
{
display: inline-block;
text-align: center;
cursor: pointer;
overflow: hidden;
}
.button a
{
display: inline-block;
height: 100%;
}
.button a:before //So its contents vertically-align
{
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em;
}
.button-container
{
display: inline-block;
vertical-align: middle;
text-align: center;
}
.button-icon
{
font-size: 180%;
}
.button-label
{
font-size: 90%;
}
It only happens with the "Log In" button (but I included two of them in case it helps). The buttons are contained within a div that has text-align: right;, in case that's relevant.
It renders well on Firefox Mobile, and on desktop, of course. I tested it on Chrome Beta v42, and the most recent version of regular Chrome Mobile, I guess maybe it's a Webkit thing, but I wonder if it's a known issue, and if there are any workarounds, or at least an explanation as to why it happens.
I want to create a rounded button in BS3 (a perfect circle), with a single fontawesome(4.0) icon in the center.
So far, I have the following code:
HTML:
<i class="fa fa-user"></i>
What would the CSS markup be to make this button a perfect circle?
you can do something like adding a class to add border radius
HTML:
<i class="fa fa-user"></i>
CSS:
.btn-circle {
width: 30px;
height: 30px;
text-align: center;
padding: 6px 0;
font-size: 12px;
line-height: 1.42;
border-radius: 15px;
}
in case you wanted to change dimension you need to change the font size or padding accordingly
(Not cross-browser tested), but this is my answer:
.btn-circle {
width: 40px;
height: 40px;
line-height: 40px; /* adjust line height to align vertically*/
padding:0;
border-radius: 50%;
}
vertical center via the line-height property
padding becomes useless and must be reset
border-radius independant of the button size
Boostrap 3 has a component for exactly this. It's:
<span class="badge">100</span>
This is the best reference using font-awesome.
http://bootsnipp.com/snippets/featured/circle-button?
CSS:
.btn-circle { width: 30px; height: 30px; text-align: center;padding: 6px 0;font-size: 12px;line-height: 1.428571429;border-radius: 15px;}.btn-circle.btn-lg {width: 50px;height: 50px;padding: 10px 16px;font-size: 18px;line-height:1.33;border-radius: 25px;}
With Font Awesome ICONS, I used the following code to produce a round button/image with the color of your choice.
<code>
<span class="fa fa-circle fa-lg" style="color:#ff0000;"></span>
</code>
I had the same problem and came up with a very simple solution working for all (xs, sm, normal and lg) buttons more or less:
.btn-circle {
border-radius: 50%;
padding: 0.1em;
width:1.8em;
}
The difference between the btn-xs and -sm are only their padding. And this is not covered with this snippet. This snippet calculates the sizes based on the font-size only.
If you have downloaded these files locally then you can change following classes in bootstrap-social.css, just added border-radius: 50%;
.btn-social-icon.btn-lg{height:45px;width:45px;
padding-left:0;padding-right:0; border-radius: 50%; }
And here is teh HTML
<a class="btn btn-social-icon btn-lg btn-twitter" >
<i class="fa fa-twitter"></i>
</a>
<a class=" btn btn-social-icon btn-lg btn-facebook">
<i class="fa fa-facebook sbg-facebook"></i>
</a>
<a class="btn btn-social-icon btn-lg btn-google-plus">
<i class="fa fa-google-plus"></i>
</a>
It works smooth for me.
Use font-awesome stacked icons (alternative to bootstrap badges). Here are more examples: http://fontawesome.io/examples/
.no-border {
border: none;
background-color: white;
outline: none;
cursor: pointer;
}
.color-no-focus {
color: grey;
}
.hover:hover {
color: blue;
}
.white {
color: white;
}
<button type="button" (click)="doSomething()"
class="hover color-no-focus no-border fa-stack fa-lg">
<i class="color-focus fa fa-circle fa-stack-2x"></i>
<span class="white fa-stack-1x">1</span>
</button>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
To add a rounded border in any button the best way is to add the border-radius property. I belive this class is better because you can add-it at any button size. If you set the height and widht you will need to create a "rouding" class to each button size.
.btn-circle {
border-radius: 50%;
}
<button class='btn-circle'>Click Me!</button>
<button class='btn-circle'>?</button>
I'm a new user to StackOverflow. Looking forward to be part of your wonderful community. My question is as follows:
I want to use a Twitter Bootstrap modal box on my website. However, I'm facing problems getting the CSS to work on the modal box. I wrote the following HTML code:
<div id="playModal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<span class="login"><strong>Login</strong></span>
</div>
<div class="modal-body">
<form class="form-horizontal" accept-charset="utf-8" method="post" action="#">
<fieldset>
<div class="control-group">
<label class="control-label" for="play_form_username">Username</label>
<div class="controls">
<input type="text" id="play_form_username" name="username" placeholder="Enter your username" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="play_form_password">Password</label>
<div class="controls">
<input type="password" id="play_form_password" name="password" placeholder="Enter your password" required />
</div>
</div>
</fieldset>
<span>Forgot your password?</span>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Play!</button>
</div>
</form>
</div>
<div class="modal-footer">
<span>Not a member yet? Join Now!</span>
<!--need to find a way to get this modal box to disappear if registerModal is called-->
</div>
</div>
Next, I want to configure the design of the page. I am using LESS to write code which is converted to CSS through SIMPLESS. I tried passing my desired CSS configuration through the modal div ID in the following LESS code:
#playModal{
width: 300px;
.modal-backdrop,
.modal-backdrop.fade.in{
opacity: 1;
filter: alpha(opacity=100);
}
.modal-header{
.login{
font-family: arial;
font-size: 60px;
font-weight: bolder;
}
}
.modal-body{
max-height: 200px;
}
}
This compiles successfully to CSS, but when I analyse the webpage using Firebug, it appears that none of the CSS has been passed for the modal box. Instead, if I use pass the CSS configurations by class, similar to the following, it works.
.modal{
width: 315px;
margin-left: 0px;
left: 50%;
top: 58px;
.modal-header{
padding: 7px 15px;
.login{
color: #203665;
font-size: 20px;
font-weight: bolder;
line-height: 24px;
}
}
}
Why is it that the CSS rules are not passed when referring to the modal box by ID? Isn't ID be more specific than class? Note: even when i use !important on the code using ID, it doesn't work.
It will be greatly appreciated if someone can help me out- though it's probably because I did something stupid. (The context why I need to use ID and not just class is: I'm needing to add a second modal box, and I want it to have different size, field sizes etc.) Thanks.
EDIT: (Answers my own silly question)
After dabbling around with the code, I found that the following works:
//Settings for all models
.modal-backdrop.fade.in{
opacity: 0.9!important;
filter: alpha(opacity=90)!important;
}
//Settings for playModal
#playModal{
width: 315px;
margin-left: 0px;
left: 50%;
top: 58px;
.modal-header{
padding: 7px 15px;
.login{
color: #203665;
font-size: 20px;
font-weight: bolder;
line-height: 24px;
}
}
.modal-body{
padding: 10px;
.control-group{
margin-bottom: 10px;
.control-label{
width: 65px;
text-align: left;
}
.controls{
margin-left: 75px;
}
}
span a{
display: block;
margin-top: 0px;
padding-top: 15px;
float: left;
&:hover{
text-decoration: none;
}
}
.form-actions{
display: block;
float: right;
margin: 0px;
padding: 0px;
border: 0px;
background-color: #FFFFFF;
.btn{
font-size: 18px;
line-height: 24px;
}
}
}
.modal-footer{
padding: 7px!important;
}
}
I think what I did wrong was to put the .modal-backdrop.fade.in inside the #playModal, it dawns on me now that .modal-backdrop.fade-in would be referring to the area outside of the #playModal div.
So all in all it was just a trivial mistake that got me worked up for so many hours. Sorry to waste everyone's time. What a way to start on StackOverflow. But anyway thanks everyone for trying to help me out. Please vote to close this post.
You're using the wrong case.
You give the element the id, playModal
Your css refers to #playmodal
Css is case-sensitive.