CSS issue- inline-block is not working - css

I am trying to place two elements side by side. I used css inline block but surprisingly its not working.
<div class="item-body" style="display:inline-block">
<!--- Element 1--->
<div style="width:150px;" class="input-group">
<div class="spinner-buttons input-group-btn">
<button ng-click="selectedItem.qnt=selectedItem.qnt===1?1:selectedItem.qnt-1;updateSelectedItemData();" class="btn spinner-down red" type="button">
<i class="fa fa-minus"></i>
</button>
</div>
<input type="text" style="text-align: center;" ng-model="selectedItem.qnt" maxlength="3" class="spinner-input form-control ng-pristine ng-untouched ng-valid ng-valid-maxlength">
<div class="spinner-buttons input-group-btn">
<button ng-click="selectedItem.qnt=selectedItem.qnt+1;updateSelectedItemData()" class="btn spinner-up green-haze" type="button">
<i class="fa fa-plus"></i>
</button>
</div>
</div>
<!--- Element 2--->
<div > x {{i.item_qnt}}={{item_subtotal}}</div>
</div>
Element 1 and element 2 is appearing in different line

You need to apply display: inline-block; to each element that you want to be displayed in the same line, not to their parent container. I've added background-color so it's clearly visible where each <div> is exactly located. For both inline-blocks to be aligned vertically, use css property vertical-align.
.item-body > div {
vertical-align: text-top;
}
<div class="item-body">
<!--- Element 1--->
<div style="display: inline-block; width:150px; background-color: #f8f8f8;">
<div>
<button>-</button>
</div>
<input type="text" style="text-align: center;">
<div>
<button>+</button>
</div>
</div>
<!--- Element 2--->
<div style="display:inline-block; background-color: #ddd;"> x {{i.item_qnt}}={{item_subtotal}}</div>
</div>

Related

Materializecss center inside container

I am using the materializecss framework: http://materializecss.com
I want to have a login form inside the middle of the container:
I already tried setting the container div to 100% but that makes it 100% + the navbar so it will add a scrollbar. This is my html how I have it now:
<div class="container">
<router-outlet></router-outlet>
<app-login>
<div class="valign-wrapper full-height">
<div class="center-block">
<form novalidate="" class="ng-untouched ng-pristine ng-valid">
<div class="input-field">
<i class="material-icons prefix">perm_identity</i>
<input id="username" type="text">
<label for="username" class="">Gebruikersnaam</label>
</div>
<div class="input-field">
<i class="material-icons prefix">lock</i>
<input id="password" type="password">
<label for="password">Wachtwoord</label>
</div>
<div class="valign-wrapper">
<button class="btn waves-effect waves-light center-block" name="login" type="submit">
Inloggen
</button>
</div>
</form>
</div>
</div>
</app-login>
</div>
I did see some answers on stackoverflow but those don't really make it responive and most of them are position: absolute which I dont want because I want it inside the container.
Give the div an ID.
Then, in style.css add:
#id {
width: 100%;
height: 100%;
}

how do you adjust bootstrap form and button to be the same height inside a div?

I have the below HTML and CSS - how do I make the search-bar and add-contacts the same height? I currently have their height set to 100% in CSS to expand inside their container div but that doesn't work Is it possible to change their height even though they are bootstrap units?
HTML
<div className="container">
<form className="form-inline search-bar" role="form">
<div className="form-group has-success has-feedback">
<label className="control-label" htmlFor="inputSuccess4"></label>
<input type="text" className="form-control" id="inputSuccess4" type="text" placeholder="Search" onChange={handleChange}/>
<span className="glyphicon glyphicon-search flipped form-control-feedback"></span>
</div>
</form>
<div className="add-contacts">
<button type="button" className="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
+ Contacts Keeper
</button>
</div>
</div>
CSS
.table-container {
margin: 20px;
}
.search-bar {
margin-left: 20px;
float: left;
height: 100%;
}
.add-contacts {
margin-right: 20px;
float: right;
height: 100%;
}
Just change the height of the search bar.
Or you could put search bar in same div as add contacts bar.
I find simpler is better with Bootstrap. I try to avoid adding custom CSS for most of the HTML elements already styled by Bootstrap:
<div class="container">
<div class="row">
<div class="col-md-12">
<form class="form-horizontal">
<div class="col-md-3 text-left">
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Search</label>
<div class="input-group">
<input type="text" class="form-control" id="exampleInputAmount" placeholder="Search">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
</div>
</div>
</div>
<div class="col-md-6"></div>
<div class="col-md-3 text-right">
<button type="submit" class="btn btn-primary">+ add stuff</button>
</div>
</form>
</div>
</div>
</div>

Inline everything inside div bootstrap

I'm trying to align horizontally a h2 and bottom inside of a div using bootstrap and css. My code is below.
<div class="col-md-9">
<div class="alert alert-info">
<i class="fa fa-coffee"></i>
Use this form to update your profile.
</div>
<div>
<h3>Personal info</h3>
<button class="btn btn-danger" href="#">Edit</button>
</div>
</div>
You can try this
<div class="check">
<h3>Personal info</h3>
<button class="btn btn-danger" href="#">Edit</button>
</div>
.check h3,.check button{
display:inline-block;
}
Working JSfiddle

How to get every line of text / elements of a page centered horizontally?

I am trying to have every line of text/elements centered horizontally so that my page looks lke this https://hootsuite.com/.
How do I style the page in CSS to look like that ?
Here is my page :
<div class ="wrap">
<% if user_signed_in? %>
<div class="row">
<aside class="col-md-4">
<section class="user_info">
<%= render 'shared/user_info' %>
</section>
<hr/>
<br/>
<section class="stats">
<%= render 'shared/stats' %>
</section>
<section class="post_form">
<%= render 'shared/post_form' %>
</section>
</aside>
<section class="post_feed">
<br>
<h3>Post Feed</h3>
<%= render 'shared/feed' %>
</section>
</div>
</div>
<% else %>
</aside>
<div class="row">
<div class="fb-like"
data-share="true"
data-width="450"
data-show-faces="true"></div>
<h2>Join <%= [2000, User.all.count].max %>+ artists.</h2>
<!-- <iframe src="terms" width= "100%" height= "600"></iframe>-->
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<div class="col-lg-10">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
<div class="checkbox">
<label>
<input type="checkbox"> I agree to the terms and conditions.
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-default">Log in</button>
<button type="submit" class="btn btn-primary">Sign up</button>
</div>
</div>
</fieldset>
</form>
<button type="submit" class="btn btn-info"><i class="fa fa-facebook"></i> Login with Facebook</button>
<br/>
<br/>
<button type="submit" class="btn btn-primary"><i class="fa fa-twitter"> </i> Login with Twitter </button>
<br/>
<br/>
<button type="submit" class="btn btn-default"><i class="fa fa-linkedin"></i> Login with LinkedIn</button>
<br/>
<br/>
<button type="submit" class="btn btn-primary btn-warning"><i class="fa fa-google"></i> Login with Google </button>
<br/>
</div>
</section>
</div>
<%end%>
</div>
And my CSS:
.wrap{
display: inline-block
text_align: center ;
width:50%;
margin-left: auto ;
margin-right: auto ;
}
Not everything is centered on that page. The body text is aligned to the left. There are a couple of ways to center things.
1) adding the rule text-align: center to an element aligns to the center the child elements that don't have full width.
2) adding width: 50%; margin-left: auto; margin-right: auto aligns to the center an element that has a fixed width.
3) You can center things using flexbox. Go here to learn more abou this.
I think this should answer your questions.
body {
text-align: center;
margin-left: auto;
margin-right: auto
}
Note that elements that aren't inline, such as divs, will need to have a width defined in order for the margin: left/right styles to work.
Example:
.example-style {
width: 50%;
}
<div class="example-style">This content will be aligned in the center because all body elements are set to be centered by default.</div>
Setting elements as display: inline-block with text-align: center on the parent element will center most elements, as long as you aren't using any floats.

Two separate columns of buttons

I was wondering if anyone could tell me how to space out 6 buttons. I want is so that three of the buttons are at the top, while the other 3 are below the top row. So basically it would be two separate rows of aligned buttons.
I know this seems fairly easy but I'm having a difficult time with it. Any help is really appreciated. Thanks.
You could simply do something as such:
<div id="button-wrapper">
<div class="button-row">
<input type="button" value="button1" />
<input type="button" value="button2" />
<input type="button" value="button3" />
</div>
<div class="button-row">
<input type="button" value="button4" />
<input type="button" value="button5" />
<input type="button" value="button6" />
</div>
</div>
You could do something like
#top
{
width: 100%
}
#bottom
{
width: 100%;
}
.button
{
float: left
width: 33%;
}
<div id="top">
<div class="button">
<!-- code for button here -->
</div>
<div class="button">
<!-- code for button here -->
</div>
<div class="button">
<!-- code for button here -->
</div>
</div>
<div id="bottom">
<div class="button">
<!-- code for button here -->
</div>
<div class="button">
<!-- code for button here -->
</div>
<div class="button">
<!-- code for button here -->
</div>
</div>
You can play with the button div width and add margins/padding ect.
To ensure column alignment, you could add a column class to each, and specify a width in that column class.
HTML:
<div id="button-wrapper">
<div class="button-row">
<input type="button" value="blah blah" class="c0"/>
<input type="button" value="lorem ipsum" class="c1"/>
<input type="button" value="really long button label" class="c2"/>
</div>
<div class="button-row">
<input type="button" value="button4" class="c0"/>
<input type="button" value="button5" class="c1"/>
<input type="button" value="button6" class="c2"/>
</div>
</div>
CSS:
.c0{
width: 80px;
}
.c1{
width: 100px;
}
.c2{
width: 150px;
}

Resources