HTML / locate button and text in the same line - html

I have two element in my HTML code. One, is a text:"Machine" and the other is a button which need to be in the right panel (but in the sane line..).
<div class="panel panel-default">
<div class="panel-heading" style="align: center"> <strong class="">Machine</strong>
<div ng-show="app[11]">
<button style="float: right;" class="btn btn-sm btn-primary btn-danger" type="submit" ng-click="submitForm11(app[1])">Delete</button>
</div>
</div>
For some reason, the button appear beneath the text, and not beside it.
What can be the reason?
Edit:
I change it to the next code, after the answer suggestion:
<div class="panel panel-default">
<div class="panel-heading" style="align: center;"> <strong class="">Machine</strong>
<div style="float: right;" ng-show="app[11]">
<button class="btn btn-sm btn-primary btn-danger" type="submit" ng-click="submitForm11(app[1])">Delete</button>
</div>
</div>
It's still gives me the same result:
I close the first <div> later.

you didn't close your first div.
<div class="panel panel-default">
<div class="panel-heading" style="align: center; float:right;">
<strong class="">Machine</strong>
</div>
<div style="float:right;" ng-show="app[11]">
<button class="btn btn-sm btn-primary btn-danger" type="submit" ng-click="submitForm11(app[1])">Delete</button>
</div>
</div>
and now you can change line-height of the text div to have a better position beside your button.

Don't float anything. dive both divs inside panel-default display:inline-block; vertical-align:middle; and it will center them on the same horizontal line.
.panel-default{
> *{ display:inline-block; vertical-align:middle; }
}

You could put the <button> along with its surrounding <div> inside the <div class="panel-heading"> and move the float property from <button> to <div>, like so:
<div class="panel panel-default">
<div class="panel-heading" style="align: center;"> <strong class="">Machine</strong>
<div style="float: right;" ng-show="app[11]">
<button class="btn btn-sm btn-primary btn-danger" type="submit" ng-click="submitForm11(app[1])">Delete</button>
</div>
</div>
</div>
http://jsfiddle.net/n6tp90s7/
Your code was missing one closing </div>, so I am not sure if that was your intention from the start.

<div id="box">Machine<div id="button">delete</div></div>
and css:
#box {width:200px; height:40px; line-height:40px; padding-left:5px;}
#button {width:70px; height:36px; float:right; margin:2px 5px; background:#ff0000;}
with this, you'll get the result you want. And you can add the codes you didn't write...

Related

Unable to force Bootstrap button with alert class to show the alert text on its left side

Hi all I have created two buttons in alligned in the two sides of my web page, one on the left and one the right side. Each button upon its click shows an alert text on its relevant side like in the picture
The code that I have used is the following :
<div class="row">
<div class="col-lg-6">
<div class="previous">
<button type="button" id="button_1" class="btn btn-primary btn-lg">Button1</button>
<span id="alert_info_1" class="alert alert-info">
Alert Info
</span>
</div>
</div>
<div class="col-lg-6 text-left">
<div class="next" >
<button type="button" id="button_2" class="btn btn-primary btn-lg">Button2</button>
<span id="alert_info_2" class="alert alert-info ">
Alert Info
</span>
</div>
</div>
</div>
While the css for the alignment of the buttons :
.previous {
text-align: left;
}
.next {
text-align: right;
}
What I'd like to do is to make the alert info text of the button 2 to appear on the left side of the button and not on the right as it is show on the above picture
I've tried to add text-left in the button class but didn't work.
I also tried to add pull-left class in the span class, it forced the text to the left but the alert text appeared quite far from the button 2 as in the following image:
Does anyone has any idea how to fix this ?
just replace your second button and alert box then it will work and if you do not change your html , so need to add some extra css
.previous {
text-align: left;
}
.next {
text-align: right;
}
<link rel="stylesheet prefetch" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<div class="row">
<div class="col-xs-6">
<div class="previous">
<button type="button" id="button_1" class="btn btn-primary btn-lg">Button1</button>
<span id="alert_info_1" class="alert alert-info">
Alert Info
</span>
</div>
</div>
<div class="col-xs-6 text-left">
<div class="next">
<span id="alert_info_2" class="alert alert-info ">Alert Info</span>
<button type="button" id="button_2" class="btn btn-primary btn-lg">Button2</button>
</div>
</div>
</div>
Swap second span and button:
.previous {
text-align: left;
}
.next {
text-align: right;
}
<link rel="stylesheet prefetch" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<div class="row">
<div class="col-xs-6">
<div class="previous">
<button type="button" id="button_1" class="btn btn-primary btn-lg">Button1</button>
<span id="alert_info_1" class="alert alert-info">
Alert Info
</span>
</div>
</div>
<div class="col-xs-6 text-left">
<div class="next">
<span id="alert_info_2" class="alert alert-info ">Alert Info</span>
<button type="button" id="button_2" class="btn btn-primary btn-lg">Button2</button>
</div>
</div>
</div>

Bootstrap 3 Panel Header with Buttons Set to Not Respect Parent Padding

Here's my fiddle to demonstrate what I have now:
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left" style="padding-top: 7.5px;">Panel Title</h4>
<div class="btn-group pull-right">
<button type="button" class="btn btn-default">Button A</button>
<button type="button" class="btn btn-default">Button B</button>
<button type="button" class="btn btn-default">Button C</button>
</div>
</div>
<div class="panel-body">
Panel content.
</div>
</div>
What I want to happen is for the buttons to have the full-height of the panel (such that there is no space, top and bottom) and to have it move to the edge (such that there is no space on the right side).
I'm thinking of using negative margins and setting the height of the buttons, but that seems hacky? Is there no better way, a class, maybe, that I can use?
Check out the fiddle
There is a padding on the panel-heading that you need to remove.
.option-button {
height:100%;
}
.media-object {
height: 50;
}
.panel-heading {
padding: 0;
}
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left">Panel Title</h4>
<div class="btn-group pull-right media-object">
Button A
Button B
Button C
</div>
</div>
<div class="panel-body">
Panel content.
</div>
</div>

Button is not working in html

I have the following code here:
<div class="container-fluid">
<div class="row-fluid">
<div class="centering col-lg-8 topSection" style="text-align: center;">
<div class="col-lg-12" style="padding-top: 160px;">
<h2 style="color: #fff; font-size: 30px;">Get discovered - Discover - Connect</h2>
<h3 style="color: #fff; font-size: 23px;">We love everyting about music. The scene. The people. The livestyle. We live for it.</h3>
<button type="submit" class="btn_style_1 btn" data-toggle="modal" data-target="#myModalLogin">Sign in</button>
<button type="submit" class="btn_style_1 btn" data-toggle="modal" data-target="#myModal">Join now</button>
</div>
</div>
</div>
</div>
When I run the application, the buttons are not working. Nothing happens when I click on the buttons. The cursor Is not transformed to a pointer when I hover the buttons.
However, when I remove centering col-lg-8 topSection, the Sign in button works, but not the other button.
Have anyone had the same problem?
EDIT:
I had this In my Layout.cshtml:
<div class="col-lg-12">
#RenderBody()
</div>
When I removed the div, It worked.
Remove the type="submit" or replace it with type="button". Your solution would be:
<button type="button" class="btn_style_1 btn" data-toggle="modal" data-target="#myModalLogin">Sign in</button>
<button type="button" class="btn_style_1 btn" data-toggle="modal" data-target="#myModal">Join now</button>

Float:right not working? [Bootstrap 3 Panel]

I am working on a bootstrap 3 project at the moment and i have added a button called "Add Shipment, i want this button to stay fixed to the right hand side of the panel but when I give it the style of float:right or class of pull-right, it doesn't work.
The design must be responsive so therefore I cannot just give it a class of float: left and then put margin-left: XXX
Please let me know if you know how to solve this, the code and screenshot are below.
<div class="row" style="margin-top:-20px;">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-primary panel-table" style="border-radius:50px">
<div class="panel-heading" style="background-color:#EFEFEF; border: 1px solid #CCCCCC; height:45px; width:auto">
<div class="panel-title" style="padding:0; width:auto" >
<div class="input-group input-group-sm" style="width:200px; margin-top:7px; margin-left:10px; float:left">
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
<input type="text" class="form-control" placeholder="Filter">
</div>
<div class="btn-group" style="float:left; margin-left:25px; margin-top:6px">
<button type="button" class="btn btn-default">All</button>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span></button>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-road"></span></button>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-exclamation-sign"></span></button>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span></button>
</div>
<button class="btn btn-info" style="margin-top:6px; float:right">Add Shipment</button>
</div>
</div>
<div class="panel-body" style="background-color:#F2F2F2; border: 1px solid #CCCCCC; height:200px">
</div>
</div>
</div>
Current screenshot of results from that code:
I tried copying and pasting your code to see how things look, and it looks fine. I see that the Add Shipment button is pulled to the right. You must have something in your CSS stylesheet that is preventing the button from being floated to the right

Center button under form in bootstrap

i have some problems with Bootstrap. i centered form and button by using span6 offset3 and don't know how to center button under this form right now. i tried with text-align: center but still it's more on the left.
<div class="container">
<div class="row">
<div class="span6 offset3">
<form>
<input class="input-xxlarge" type="text" placeholder="Email..">
<p style="line-height: 70px; text-align: center;"><button type="submit" class="btn">Confirm</button></p>
</form>
</div>
</div>
</div>
Remove that <p> tag and add the button inside a <div class="form-actions"> like this:
<div class="form-actions">
<button type="submit" class="btn">Confirm</button>
</div>
an then augment the CSS class with:
.form-actions {
margin: 0;
background-color: transparent;
text-align: center;
}
Here's a JS Bin demo: http://jsbin.com/ijozof/2
Look for form-actions at the Bootstrap doc here:
http://twitter.github.io/bootstrap/base-css.html#buttons
With Bootstrap 3, you can use the 'text-center' styling attribute.
<div class="col-md-3 text-center">
<button id="button" name="button" class="btn btn-primary">Press Me!</button>
</div>
If you're using Bootstrap 4, try this:
<div class="mx-auto text-center">
<button id="button" name="button" class="btn btn-primary">Press Me!</button>
</div>
Width:100% and text-align:center would work in my experience
<p style="display:block; line-height: 70px; width:100%; text-align:center; margin:0 auto;"><button type="submit" class="btn">Confirm</button></p>
Try adding this class
class="pager"
<p class="pager" style="line-height: 70px;">
<button type="submit" class="btn">Confirm</button>
</p>
I tried mine within a <div class=pager><button etc etc></div> which worked well
See http://getbootstrap.com/components/ look under Pagination -> Pager
This looks like the correct bootstrap class to center this, text-align: center; is meant for text not images and blocks etc.
I do it like this <center></center>
<div class="form-actions">
<center>
<button type="submit" class="submit btn btn-primary ">
Sign In <i class="icon-angle-right"></i>
</button>
</center>
</div>
You can use this
<button type="submit" class="btn btn-primary btn-block w-50 mx-auto">Search</button>
Look something like this
Complete Form code -
<form id="submit">
<input type="text" class="form-control mt-5" id="search-city"
placeholder="Search City">
<button type="submit" class="btn btn-primary mt-3 btn-sm btn-block w-50
mx-auto">Search</button>
</form>
Using Bootstrap, the correct way is to use the offset class. Use math to determine the left offset. Example: You want a button full width on mobile, but 1/3 width and centered on tablet, desktop, large desktop.
So out of 12 "bootstrap" columns, you're using 4 to offset, 4 for the button, then 4 is blank to the right.
See if that works!
With Bootstrap you can simply use class text-center:
<div class="container">
<div class="row">
<form>
<input class="input-xxlarge" type="text" placeholder="Email..">
</form>
<div class="text-center">
<button type="submit" class="btn">Confirm</button>
</div>
</div>
</div>
DEMO
Try giving default width, display it with block and center it with margin: 0 auto;
like this:
<p style="display:block; line-height: 70px; width:200px; margin:0 auto;"><button type="submit" class="btn">Confirm</button></p>
It's working completely try this:
<div class="button pull-left" style="padding-left:40%;" >