Modal Footer-Ajax message centering in the modal footer - css

I have this modal footer with a <label></label> which displays message on successful operation. But, the properties are inherited so the style for centering is not working. I am using Bootstrap 3.3.7
<div class="modal-footer">
<label type="text" id="resultmessage" style="color: white; vertical-align:middle;"></label>
<button type="button" id="updateWorksStatus" class="btn btn-success btn-sm">Update Status</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
</div>

Add a more specific CSS selector to override bootstrap styles (.modal-footer is set to text-align: right by default.).
div.modal-footer {
text-align: center;
}
Also, you can switch label order to last element inside of .modal-footer if you wish for it to be on the right side of buttons (changed color to gray just for visibility).
Snippet:
div.modal-footer {
text-align: center;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="modal-footer">
<button type="button" id="updateWorksStatus" class="btn btn-success btn-sm">Update Status</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
<label type="text" id="resultmessage" style="color: gray; vertical-align:middle;">Database updated</label>
</div>
If you wish to only center the message, you can do (tweak values to your benefit):
.modal-footer button {
margin-top: -48px;
}
#resultmessage {
display: inline-block;
width: 100%;
text-align: center;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="modal-footer">
<label type="text" id="resultmessage" style="color: gray; vertical-align:middle;">Database updated</label>
<button type="button" id="updateWorksStatus" class="btn btn-success btn-sm">Update Status</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
</div>

In my opinion, using label as not label for nothing is not good pratice. I'm quessing that u want this information ('Database updated') aligne vertically (you have tried to use vertical-align - it only works for tables). Instead of using label, better is to use for example span.
I did it like below:
https://codepen.io/Czeran/pen/BdWbjg
HTML
<div class="modal-footer">
<span id="resultmessage">Database updated</span>
<div class="tools">
<button type="button" id="updateWorksStatus" class="btn btn-success btn-sm">Update Status</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
</div>
<span></span>
</div>
CSS (edited)
.modal-footer {
position: relative;
display: flex;
flex-direction: row-reverse;
align-items: center;
justify-content: center;
}
#resultmessage {
font-weight: bold;
}
.tools {
position: absolute;
right: 15px;
}

Related

The buttons do not come out side by side

I'm having a problem. I set up my css by setting the buttons side by side, only it's not working.
#btn1, #btn2, #btn3{
width: 200px;
height: 40px;
}
<a class="btn btn-success" id="btn1" href="{{route('wineshop.edit', compact('wineshop'))}}">EDIT</a>
<form action="{{route('wineshop.destroy', compact('wineshop'))}}" method="post">
#method('delete')
#csrf
<button type="submit" id="btn2" class="btn btn-danger">DELETE</button>
</form>
<a class="btn btn-primary" id="btn3" href="{{route('wineshop.index')}}">BACK</a>
Can anyone kindly help me?
Set with Outer div Flex Style
#btn1, #btn2, #btn3
{
width: 200px;
height: 40px;
}
.btn_outer {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
<div class="btn_outer">
<a class="btn btn-success" id="btn1" href="{{route('wineshop.edit', compact('wineshop'))}}">EDIT</a>
<form action="{{route('wineshop.destroy', compact('wineshop'))}}" method="post">
#method('delete')
#csrf
<button type="submit" id="btn2" class="btn btn-danger">DELETE</button>
</form>
<a class="btn btn-primary" id="btn3" href="{{route('wineshop.index')}}">BACK</a>
</div>

Cannot alter Bootstrap button

<button class="btn btn-default">Click me</button>
I want to alter this button by reducing it's padding to 0px, so I added an extra class no-padding in style.css
.no-padding {
padding-left: 0;
padding-right: 0;
}
and called it like
<button class="btn btn-default no-padding">Click me</button>
But still I'm getting the same class
and If I use inline style statement, it works perfectly, but I don't want to do it in that way
Thanks!!
for that you need to know specificity concept of CSS
you can do like this
button.no-padding {
padding-left: 0;
padding-rigt: 0;
}
and your CSS works fine. You see difference in below snippet
button.no-padding {
padding-left: 0;
padding-right: 0;
}
.no-padding1 {
padding-left: 0;
padding-right: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<button class="btn btn-default no-padding">Click me</button>
<button class="btn btn-default no-padding1">Click me</button>
You can use Bootstrap padding classes.
1 > px : padding at left and right. 2 > py : padding at top and
botton.
See more examples given below
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
Your Button as it is :
<button class="btn btn-default ">Click me</button>
<br/>
<br/>
Button with px class :
<button class="btn btn-primary px-0">Click me</button>
<br/>
<br/>
Button with py class
<button class="btn btn-warning py-0">Click me</button>
<br/>
<br/>
Button with px and py class :
<button class="btn btn-success px-0 py-0">Click me</button>
<br/>
<br/>
Button with pl class
<button class="btn btn-danger pl-0">Click me</button>
<br/>
<br/>
Button with pr class :
<button class="btn btn-success pr-0">Click me</button>

Bootstrap button text is not responsive

I tried many things to get the button text responsive, but it is not working.
Here's my html code
<button style="margin-top : 5px;"
type="submit" class="btn btn-primary cd-admin-create-modal-btn" ng-disabled = "form.$invalid"
ng-click="submitRouterDtls(router);">Submit
</button>
<button style="margin-top : 5px;"
type="submit" class="btn btn-primary cd-admin-create-modal-btn"
ng-click="cancelOperation();">Cancel
</button>
Here's my css code
.cd-admin-create-modal-btn {
width: 5vw;
margin: 0 1vw;
font-size : 1.5vw;
}
Can someone help me?
try it
.cd-admin-create-modal-btn {
min-width: 10vw;
margin: 0 1vw;
font-size : 1.5vw;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<button style="margin-top : 5px;"
type="submit" class="btn btn-primary cd-admin-create-modal-btn" ng-disabled = "form.$invalid"
ng-click="submitRouterDtls(router);">Submit
</button>
<button style="margin-top : 5px;"
type="submit" class="btn btn-primary cd-admin-create-modal-btn"
ng-click="cancelOperation();">Cancel
</button>

Styling multiple POST actions as a Bootstrap button group

I have multiple "POST" buttons (empty forms with a single submit button) to handle some actions which have side-effects. I need to make these buttons appear as a Bootstrap button group (.btn-group) as if they were a tags with a .btn class applied.
My first idea was to reproduce all the css styles Bootstrap uses for .btn-groups but with a form child element instead of .btn. Well it turns out there are a lot of styles involved! I'm hoping there's another solution. I included the very first basic style needed to have buttons in a single line in the snippet. Many more styles are needed to manage the borders, rounded corners, etc.
.btn-group.try1 > form {
position: relative;
float: left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<h1>Doesn't work</h1>
<div class="btn-group">
<form method="post" action"./action1">
<button type="submit" class="btn btn-danger">Action with side-effect 1</button>
</form>
<form method="post" action"./action2">
<button type="submit" class="btn btn-default">Action with side-effect 2</button>
</form>
<form method="post" action"./action3">
<button type="submit" class="btn btn-warning">Action with side-effect 3</button>
</form>
</div>
<h1>Desired appearance</h1>
<div class="btn-group">
Action with side-effect 1
Action with side-effect 2
Action with side-effect 3
</div>
<h1>Attempt 1</h1>
<div class="btn-group try1">
<form method="post" action"./action1">
<button type="submit" class="btn btn-danger">Action with side-effect 1</button>
</form>
<form method="post" action"./action2">
<button type="submit" class="btn btn-default">Action with side-effect 2</button>
</form>
<form method="post" action"./action3">
<button type="submit" class="btn btn-warning">Action with side-effect 3</button>
</form>
</div>
Why do I use forms?
actions with side-effects should use POST.
I'd rather not use javascript to POST where vanilla HTML works just fine.
You can create a class modifier and use it with bootstrap's .form-group class.
.form-group--flex {
display: flex;
flex-wrap: wrap;
}
.form-group--flex button {
border-radius: 0;
}
Then for the border-radius you can use pseudo-selectors.
.form-group--flex form:first-of-type button {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.form-group--flex form:last-of-type button {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
Code Snippet:
.form-group--flex {
display: flex;
flex-wrap: wrap;
}
.form-group--flex button {
border-radius: 0;
}
.form-group--flex form:first-of-type button {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.form-group--flex form:last-of-type button {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-group form-group--flex">
<form method="post" action "./action1">
<button type="submit" class="btn btn-danger">Action with side-effect 1</button>
</form>
<form method="post" action "./action2">
<button type="submit" class="btn btn-default">Action with side-effect 2</button>
</form>
<form method="post" action "./action3">
<button type="submit" class="btn btn-warning">Action with side-effect 3</button>
</form>
</div>
Notes:
The only thing that bootstrap's class .form-group does is add a margin bottom.
.form-group {
margin-bottom: 15px;
}

fontawesome icon not rendering the same in Chrome and Firefox

In Chrome/Safari my icon within a bootstrap button looks fine:
But in Firefox, the icon drops down a line:
I have the fontawesome icon floated right within the <button>.
<!--html-->
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-small">Cached logs<i class="fa fa-money"></i></button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-small">Logs on mount<i class="fa fa-database"></i></button>
</div>
</div>
<!--style-->
i.fa {
float: right;
top: 2px;
position: relative;
font-size: 12pt;
}
.glyphicon, i.fa {
color: rgb(90, 90, 90);
top: 1px;
}
How can I make the Firefox version one-line like the Chrome?
JSBIN
Move the icon to the left of the text. I'm not sure of the underlying cause of it not being consistent how you've got it - but this does make both browsers render it consistently.
<button type="button" class="btn btn-default btn-small"><i class="fa fa-database"></i>Logs on mount</button>
Instead of
<button type="button" class="btn btn-default btn-small">Logs on mount<i class="fa fa-database"></i></button>

Resources