I was attempting to float right a few items in a row
I want layout to look like this, even with reducing the browser size
Essentially this image layout is a bit different, but it shows a Create new User and Actions, so Action is like my "Manage bulk users"
I just want the items to align or float to the right, so that if the browser size is reduced it is not easily stacking on top of each other
<div class="container">
<div class="row">
<div class="col-md-4">
Choose your preferred criteria values and click Search
</div>
<div class="col-md-8 margin-top-bottom-8">
<div class="col-md-6 float-right">
<img src="assets/images/addIcon.svg" (click)="createNewUser()" />
<span (click)="createNewUser()">Create New User</span>
</div>
<div class="col-md-6 float-right">
<img src="assets/images/bulkUploadIcon.svg" (click)="openEditPopup(role)" />
<span (click)="openEditPopup(role)">Manage Bulk Users</span>
</div>
</div>
</div>
</div>
Here is a fiddle of my code pasted below
https://jsfiddle.net/03vxqed9/
you need to use pull-left and pull-right instead of float. See snippet bellow.
use a clearfix class to reset the floated elements.
Hope this will work for you!
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-4 pull-left">
Choose your preferred criteria values and click Search
</div>
<div class="col-md-8 margin-top-bottom-8 pull-right">
<div class="col-md-6 pull-right">
<img src="assets/images/addIcon.svg" (click)="createNewUser()" />
<span (click)="createNewUser()">Create New User</span>
</div>
<div class="col-md-6 pull-right">
<img src="assets/images/bulkUploadIcon.svg" (click)="openEditPopup(role)" />
<span (click)="openEditPopup(role)">Manage Bulk Users</span>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
Try This:
HTML Code
<div class="container">
<div class="row top-bar">
<div class="col-md-6 panel-left">
Choose your preferred criteria values and click Search
</div>
<div class="col-md-6 panel-right">
<div class="col-md-8 pull-right">
<img class="iconx" src="assets/images/addIcon.svg" onClick="createNewUser()" />
<span onClick="createNewUser()">Create New User</span>
</div>
<div class="col-md-6 pull-right">
<img class="iconx" src="assets/images/bulkUploadIcon.svg" onClick="openEditPopup(role)" />
<span onClick="openEditPopup(role)">Manage Bulk Users</span>
</div>
</div>
</div>
</div>
STYLES
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
.top-bar {
display:flex;width:100%;
}
.panel-right { display:flex;}
.iconx { clear:right;}
Use col-xs-6 that mean all sizes(from smallest to biggest)
and use pull-right/ pull-left instead float
float does NOT work with flex(row is flexable)
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-4 pull-left">
Choose your preferred criteria values and click Search
</div>
<div class="col-xs-8 margin-top-bottom-8 pull-right">
<div class="col-xs-6 pull-right">
<img src="assets/images/addIcon.svg" (click)="createNewUser()" />
<span (click)="createNewUser()">Create New User</span>
</div>
<div class="col-xs-6 pull-right">
<img src="assets/images/bulkUploadIcon.svg" (click)="openEditPopup(role)" />
<span (click)="openEditPopup(role)">Manage Bulk Users</span>
</div>
</div>
</div>
</div>
I hope this is what you want.
<div class="container">
<div class="row">
<div class="col-md-6 pull-left">
Choose your preferred criteria values and click Search
</div>
<div class="col-md-6 pull-right">
<div class="row">
<div class="col-md-6 pull-right">
<img src="assets/images/addIcon.svg" (click)="createNewUser()" />
<span (click)="createNewUser()">Create New User</span>
</div>
<div class="col-md-6 pull-right">
<img src="assets/images/bulkUploadIcon.svg" (click)="openEditPopup(role)" />
<span (click)="openEditPopup(role)">Manage Bulk Users</span>
</div>
</div>
</div>
</div>
</div>
Related
I am trying to implement a single page application where I want divs to display one below the other. But on resizing the viewport to various screen sizes, the positioning is getting overlapped and leaving extra spaces in between. I have codepen example to explain the problem in a better way.
https://codepen.io/SaloniDesai/pen/zPBZJr
How to make the divs appear same for every screen size ?Do i need to shuffle the way I have created the layout of the page ?
<div id="headliner" class="jumbotron text-center">
<h1>SearchGIFY app</h1>
<p>search for any GIF you want!</p>
</div>
<div id="search">
<form>
<input type="search" ng-model="vm.search.gif" value="" placeholder="type what you're looking for" />
<button type="submit" class="btn btn-primary" ng-click="vm.performSearch()">Search</button>
</form>
</div>
<div class="row">
<div class="card">
<img ng-repeat="g in vm.giphies" ng-src="{{g.images.original.url}}" height="{{g.images.fixed_height}}" title="{{g.title}}">
</div>
</div>
<div class="jumbotron text-center" id="trendingBar">
<h3>Trending gifs</h3>
<div class="row">
<div class="thumbnail">
<img ng-repeat="trending in vm.trendingGifs" ng-src="{{trending.images.original.url}}" height="{{trending.images.fixed_height.height}}" title="{{trending.title}}">
</div>
</div>
</div>
First, your bootstrap structure isn't good, there isn't container, neither rows or col.
Try this one:
<div class="container-fluid">
<div class="row">
<div id="headliner col-md-12" class="jumbotron text-center">
<h1>SearchGIFY app</h1>
<p>search for any GIF you want!</p>
</div>
</div>
<div class="row">
<div id="search">
<div class="col-md-12">
<form class="form-inline text-center col-md-6 col-md-offset-3">
<div class="form-group">
<input class="form-control" type="search" ng-model="vm.search.gif" value=""
placeholder="type what you're looking for"/>
</div>
<button type="submit" class="btn btn-primary" ng-click="vm.performSearch()">Search</button>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<img ng-repeat="g in vm.giphies" ng-src="{{g.images.original.url}}" height="{{g.images.fixed_height}}"
title="{{g.title}}">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="jumbotron text-center" id="trendingBar">
<h3>Trending gifs</h3>
<div class="thumbnail">
<img ng-repeat="trending in vm.trendingGifs" ng-src="{{trending.images.original.url}}"
height="{{trending.images.fixed_height.height}}" title="{{trending.title}}">
</div>
</div>
</div>
</div>
Second, you add a lot of absolute class with % height and width. You don't have to do that if you're using bootstrap, all the responsive stuff is handled by the bootstrap grid with col classes. Take a quick look at the grid bootstrap documentation : https://getbootstrap.com/docs/3.3/css/#grid
Here's the codepen working responsively with some modification : https://codepen.io/anon/pen/MOemgw ;)
I want to use css, bootstrap to align the first line align left, and the second line will center on the text length of the first line.
I tried many ways but not.
code follow
<div class="col-md-6">
<a href="/" style="text-decoration:none">
<div class="col-md-12 row-eq-height" style="padding:0;">
<div class="col-md-2" style="padding:0">
<img src="/Content/images/logo.png" class="img-responsive" alt="">
</div>
<div class="col-md-10 tex-center" style="padding-right:0;">
<div style="padding:0">
<div class="line1-bold">THIS IS THE FIRST LONG HEADLINE</div>
<div class="line2">THIS IS THE SECOND HEADLINE</div>
</div>
</div>
</div>
</a>
</div>
Please check this..
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="col-md-6">
<a href="/" style="text-decoration:none">
<div class="col-md-12 row-eq-height" style="padding:0;">
<div class="col-xs-2" style="padding:0">
<img src="https://www.tenforums.com/attachments/browsers-email/18558d1485951187t-microsoft-edge-logo-microsoft-edge-100582336-large.png" class="img-responsive" style="width:100px" alt="">
</div>
<div class="" style="float:left;">
<div class="line1-bold" style="color:#b63957; font-size:18px;">THIS IS THE FIRST LONG HEADLINE</div>
<div class="line2" style="color:#b63957; font-size:16px; text-align:center;">THIS IS THE SECOND HEADLINE</div>
</div>
</div>
</a>
</div>
Try adding the class text-center to your divs.
Here is a working pen.
Something like this?
I don't know about your task, but I deleted some tags.
CSS
.img-responsive {
width: 100px;
float: left;
}
span {
display: block;
}
HTML
<div class="col-md-6">
<a href="/" style="text-decoration:none">
<div class="col-md-12 row-eq-height" style="padding:0;">
<img src="https://www.tenforums.com/attachments/browsers-email/18558d1485951187t-microsoft-edge-logo-microsoft-edge-100582336-large.png" class="img-responsive" alt="">
<span class="text-left">THIS IS THE FIRST LONG HEADLINE</span>
<span class="text-center">THIS IS THE SECOND HEADLINE</span>
</div>
</a>
</div>
Reference Link
I am trying to create a top header with HTML using div row. There should be one word on the left, and the other 3 words on the left; all within the row. However, result turns out to be all four words are on different rows stacked together. I can't find nothing wrong from my codes.
<div class="container-fluid">
<div class="row" style="background-color:orange; margin:-8px; margin-top:-20px">
<div class="col-md-1">
</div>
<div class="col-md-1">
<h3>stark</h3>
</div>
<div class="col-md-6">
</div>
<div class="col-md-1">
<h3>about</h3>
</div>
<div class="col-md-1">
<h3>portfolio</h3>
</div>
<div class="col-md-1">
<h3>contact</h3>
</div>
<div class="col-md-1">
</div>
The Bootstrap .row class is defining a left and right margin of -15px.
But you overwrite this with your margin: -8px; and that's why the columns don't fit anymore into the row.
Remove margin:-8px; margin-top:-20px and it will work.
I am assuming from the classes you are using, you are using Bootstrap. Ensure the bootstrap css and javascript files are referenced. Your html seems to work properly in this fiddle:
https://jsfiddle.net/e29aju5c/
<div class="container-fluid">
<div class="row" style="background-color:orange; margin:-8px; margin-top:-20px">
<div class="col-md-1">
</div>
<div class="col-md-1">
<h3>stark</h3>
</div>
<div class="col-md-6">
</div>
<div class="col-md-1">
<h3>about</h3>
</div>
<div class="col-md-1">
<h3>portfolio</h3>
</div>
<div class="col-md-1">
<h3>contact</h3>
</div>
<div class="col-md-1">
</div>
You should have the following code (or the equivalent code pointing to your bootstrap files) somewhere on the page:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
I want to know the proper way to put an image in the center of the page, and then beside the image vertical align 2 lines of text. should I put the image and text in one bootstrap coloumn or should i have the image in one coloumn and the text in a seperate coloumn. I know there are a few ways to do this, i just want to know the proper method.
<div class="row">
<div class="col-xs-9">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" style="vertical-align:middle" />
</div>
<div class="col-xs-3">
<span style="font-size:48px;">Test</span>
<span style="font-size:24px;">Test second line. </span>
</div>
</div>
https://jsfiddle.net/k90s5fec/
This is the right way to do this
div{
display: inline-block;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-xs-8">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" style="vertical-align:middle" />
</div>
<div class="col-xs-4">
<p style="font-size:48px;">Test</p>
<p style="font-size:24px;">Test second line. </p>
</div>
</div>
This is the fiddle
NOTE : Use https:// when importing external resources,
use p tag instead of span if you want to use block texts.
use this
<div class="row">
<div class="col-xs-9">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" class="displa`enter code here`yed" />
</div>
<div class="col-xs-3">
<span style="font-size:48px;">Test</span>
<span style="vertical-align:middle; line-height: 30px;">Test second line. </span>
</div>
</div>
img.displayed
{
display: block;
margin-left: auto;
margin-right: auto
}
<div class="row">
<div class="col-md-8 col-sm-8 col-xs-8">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" style="vertical-align:middle" />
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div style="font-size:48px;">Test</div>
<div style="font-size:24px;">Test second line. </div>
</div>
</div>
Dropdown1 and Dropdown2 must float to right. Paging must be to the right.
Paging content may reduce and dropdown1 and 2 must adjust accordingly. I tried different ways but unable to get the solution. In mobile device all the three divs must be centered.
We are using bootstrap. Divs are as follows
<div class="row">
<div class="col-md-3 col-lg-3 col-sm-3 col-xs-12 alpha omega">
<!-- Title -->
</div>
<div class="col-md-6 col-lg-6 col-sm-6 col-xs-12 alpha omega">
<div style="float:right">
<ul class="nav">
<li class="dropdown">
Drop Down 2<b class="caret"></b>
<ul class="dropdown-menu " style="text-transform:uppercase;">
<li data-filterkind="$p" data-filtervalue="DESC">
<a href="./" >1</a>
</li>
<li data-filterkind="$p" data-filtervalue="ASC">
<a href="./" >2</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="pull-right">
<!-- Drop down 2 -->
</div>
</div>
</div>
<div class="col-md-3 col-lg-3 col-sm-3 col-xs-12 alpha omega">
<div style="float:right" >
<!-- Pagination -->
</div>
</div>
</div>
Please suggest
So like this?
HTML
<div class="container">
<div class="row">
<div class="col-sm-6 text-center heading1">
<p> Heading </p><!-- Heading -->
</div>
<div class="col-sm-6">
<div class="row">
<div class="float text-center">
<div class="col-sm-4">
<p> DD1</P><!-- Drop down 1 -->
</div>
<div class="col-sm-4">
<p> DD2</P><!-- Drop down 2 -->
</div>
<div class="col-sm-4">
<p> PAGINATION</P><!-- pagination -->
</div>
</div>
</div>
</div>
</div>
</div>
Then add the following additional stuff to your custom CSS:
#media (min-width: 768px)
{
.float
{
float: right;
}
.heading1
{
text-align: left;
}
}
FYI - The above is bootstrap, but the additional classes are needed to get the custom result you want.