So here is my problem. I use some ui-grid on my interface to show information, but I would like to have 2 grid of 3 columns side by side (aligned vertically). So far, I haven't found exemple of it and i tried to code it, but without success. Is there someone here with better experience then me who knows how its possible? So far, that's what i thought about the solution :
<ul data-role="listview" data-inset="true" data-icon="false">
<li data-role="list-divider">
<div class="ui-grid-b" style="width: 50%">
<div class="ui-block-a">Header 1</div>
<div class="ui-block-b">Header 2</div>
<div class="ui-block-c">Header 3</div>
</div>
<div class="ui-grid-b" style="width: 50%; float: right">
<div class="ui-block-a">Header 1</div>
<div class="ui-block-b">Header 2</div>
<div class="ui-block-c">header 3</div>
</div>
</li>
</ul>
I just try to get two table side by side like this one:https://jsfiddle.net/8o39tqgz/1/
EDIT
Just tried display: inline, but it doesn't work on the same line... https://jsfiddle.net/s71zpcgs/
How about this?
<ul data-role="listview" data-inset="true" data-icon="false">
<li data-role="list-divider">
<div class="ui-grid-b" style="width: 50%; float: left">
<div class="ui-block-a column" >Header 1</div>
<div class="ui-block-b column" >Header 2</div>
<div class="ui-block-c column" >header 3</div>
</div>
<div class="ui-grid-b" style="width: 50%; float: left">
<div class="ui-block-a column" >Header 1</div>
<div class="ui-block-b column" >Header 2</div>
<div class="ui-block-c column" >header 3</div>
</div>
</li>
</ul>
And then at your css add this
.column{
width:33%;
float:left;
/* you can optionally set a fixed height */
}
I guess its not exactly what I wanted, but that will do it. Ty to #ezanker for the solution :
HTML
<div data-role="page" id="page1">
<div data-role="header">
<h1>My page</h1>
</div>
<div role="main" class="ui-content">
<ul data-role="listview" data-inset="true" data-icon="false" class="gridUL">
<li data-role="list-divider">
<div class="ui-grid-a bothGrids">
<div class="ui-block-a">
<table class="halfGrid" style="width: 98%" >
<thead>
<tr><th>header 1</th><th>header 2</th><th>header 3</th></tr>
</thead>
<tbody>
<tr><td>content 1</td><td>Some bigger content in this cell</td><td>content 3</td></tr>
<tr><td>content 1</td><td>content 2</td><td>content 3</td></tr>
</tbody>
</table>
</div>
<div class="ui-block-b ">
<table class="halfGrid" style="width: 98%">
<thead>
<tr><th>header 1</th><th>header 2</th><th>header 3</th></tr>
</thead>
<tbody>
<tr><td>content 1</td><td>content 2</td><td>content 3</td></tr>
<tr><td>content 1</td><td>content 2</td><td>content 3</td></tr>
</tbody>
</table>
</div>
</div>
</li></ul>
</div>
</div>
CSS
.halfGrid {
margin-left: 1%;
margin-right: 1%;
border-spacing: 0;
border-collapse: collapse;
}
.halfGrid td, .halfGrid th {
border: 1px solid #aaa;
padding: 4px;
text-align: center;
width: 33%;
font-weight: normal;
white-space: normal;
}
.halfGrid th {
font-weight: bold;
}
IMPORTANT EDIT
Actually, I got the idea of splitting the screen in two and wrap one table in each side and that work exactly as I wanted! Im so happy, I was working on it for many hours... Felt like running in circle, but its finally done! Here is the code :
HTML
<div class="wrap">
<div class="fleft">
<ul data-role="listview" data-inset="true" data-icon="false" style="min-width:350px">
<li data-role="list-divider">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">PN</div>
<div class="ui-block-b" style="width:34%">Amendment</div>
<div class="ui-block-c" style="width:33%">Designation</div>
</div>
</li>
<!-- Data found -->
<li>
<a href="javascript:alert('Hello world');">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">Info1</div>
<div class="ui-block-b" style="width:34%">Info2</div>
<div class="ui-block-c" style="width:33%">Info3</div>
</div>
</a>
</li>
</ul>
</div>
<div class="fright">
<ul data-role="listview" data-inset="true" data-icon="false" style="min-width:350px">
<li data-role="list-divider">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">PN</div>
<div class="ui-block-b" style="width:34%">Amendment</div>
<div class="ui-block-c" style="width:33%">Designation</div>
</div>
</li>
<!-- Data found -->
<li>
<a href="javascript:alert('Hello world');">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">Info1</div>
<div class="ui-block-b" style="width:34%">Info2</div>
<div class="ui-block-c" style="width:33%">Info3</div>
</div>
</a>
</li>
</ul>
</div>
</div>
CSS
.wrap
{
width: 100%;
overflow:auto;
padding:2px;
}
.fleft
{
float:left;
width: 50%;
}
.fright
{
float: right;
width: 50%;
}
Found solution in this post : Split page vertically using CSS and integrated the part of my code. Here is the jsfiddle : http://jsfiddle.net/G6N5T/1211/
You could nest two 3 column grids within one 2 column grid:
<ul data-role="listview" data-inset="true" data-icon="false" class="gridUL">
<li data-role="list-divider">
<div class="ui-grid-a bothGrids">
<div class="ui-block-a">
<div class="ui-grid-b halfGrid">
<div class="ui-block-a cell">header 1</div>
<div class="ui-block-b cell">header 2</div>
<div class="ui-block-c cell">header 3</div>
</div>
</div>
<div class="ui-block-b ">
<div class="ui-grid-b halfGrid">
<div class="ui-block-a cell">Header 1</div>
<div class="ui-block-b cell">Header 2</div>
<div class="ui-block-c cell">header 3</div>
</div>
</div>
</div>
</li>
</ul>
.halfGrid {
margin-left: 1%;
margin-right: 1%;
}
.halfGrid .cell {
border: 1px solid #aaa;
padding: 4px;
text-align: center;
}
Updated FIDDLE
Related
I would like to align this entire panel center of the web page. Could someone help me out on this?
Also could you please help me a good book I can use to learn Bootstrap design?
<div class="panel panel-default" style="max-width:500px;margin-left:auto;margin-right:auto;">
<div class="panel-heading">
<h3 class="panel-title text-center">User Login</h3>
</div>
<div class="panel-body">
#Html.ValidationSummary(true)
<table class="table">
<tbody>
<tr>
<td>#Html.LabelFor(model => model.Username)</td>
<td>#Html.EditorFor(model => model.Username)</td>
<td>#Html.ValidationMessageFor(model => model.Username)</td>
</tr>
<tr>
<td>#Html.LabelFor(model => model.Password)</td>
<td>#Html.EditorFor(model => model.Password)</td>
<td>#Html.ValidationMessageFor(model => model.Password)</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Login" class="btn btn-default" style="" />
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
Thanking you
Swetha
You can remove css style from panel and wrap this as follows.
<div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-default">
...
</div>
</div>
just add
position:fixed
and it will keep it in view even if you scroll down. see it at http://jsfiddle.net/xyrkyxe8/
#mydiv {
position:fixed;
top: 50%;
left: 50%;
width:30em;
height:18em;
margin-top: -9em; /*set to a negative number 1/2 of your height*/
margin-left: -15em; /*set to a negative number 1/2 of your width*/
border: 1px solid #ccc;
background-color: #f3f3f3;
}
It worth saying that in order to center a panel, or even a group of pannels, it's also possible to use a combination of flex and justify-content property:
.row-fluid {
display: flex;
justify-content: center;
}
<script src="https://cdnjs.cloudflare.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>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row text-center row-fluid">
<div class="col-xs-3">
<div class="panel panel-default">
<div class="panel-heading">Panel 1</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">Line 1</li>
<li class="list-group-item">Line 2</li>
</ul>
</div>
</div>
</div>
<div class="col-xs-3">
<div class="panel panel-default">
<div class="panel-heading">Panel 2</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">Line 1</li>
<li class="list-group-item">Line 2</li>
</ul>
</div>
</div>
</div>
<div class="col-xs-3">
<div class="panel panel-default">
<div class="panel-heading">Panel 3</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">Line 1</li>
<li class="list-group-item">Line 2</li>
</ul>
</div>
</div>
</div>
</div>
</div>
I need to do few tables using display:table, and I trying get into BEM metodology the right way.
.b-table {
dispay: table;
width: 100%;
font-family: arial, sans-serif;
}
.b-table__cell, .b-table__header {
display: table-cell;
text-align: left;
padding: .6em;
}
.b-table__cell {
border: 1px solid #ddd;
}
.b-table__cell--half-wide {
width: 50%;
}
.b-table__cell--quarter-wide {
width: 25%;
}
.b-table__header {
background-color: orangered;
border: 1px solid red;
}
.b-table__row {
display: table-row;
width: 100%;
}
.b-table__row:nth-child(even) {
background-color: #eee;
}
<section class="sect1">
<div class="b-table">
<div class="b-table__row">
<div class="b-table__header b-table__cell--half-wide">Company</div>
<div class="b-table__header b-table__cell--quarter-wide">Contact</div>
<div class="b-table__header b-table__cell--quarter-wide">Country</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Alfreds Futterkiste</div>
<div class="b-table__cell">Maria Anders</div>
<div class="b-table__cell">Germany</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Centro comercial Moctezuma</div>
<div class="b-table__cell">Francisco Chang</div>
<div class="b-table__cell">Mexico</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Ernst Handel</div>
<div class="b-table__cell">Roland Mendel</div>
<div class="b-table__cell">Austria</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Island Trading</div>
<div class="b-table__cell">Helen Bennett</div>
<div class="b-table__cell">UK</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Laughing Bacchus Winecellars</div>
<div class="b-table__cell">Yoshi Tannamuri</div>
<div class="b-table__cell">Canada</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Magazzini Alimentari Riuniti</div>
<div class="b-table__cell">Giovanni Rovelli</div>
<div class="b-table__cell">Italy</div>
</div>
</div>
</section>
<section class="sect2">
<div class="b-table">
<div class="b-table__row">
<div class="b-table__header b-table__cell--half-wide">Company</div>
<div class="b-table__header b-table__cell--half-wide">Contact</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Alfreds Futterkiste</div>
<div class="b-table__cell">Maria Anders</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Centro comercial Moctezuma</div>
<div class="b-table__cell">Francisco Chang</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Ernst Handel</div>
<div class="b-table__cell">Roland Mendel</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Island Trading</div>
<div class="b-table__cell">Helen Bennett</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Laughing Bacchus Winecellars</div>
<div class="b-table__cell">Yoshi Tannamuri</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Magazzini Alimentari Riuniti</div>
<div class="b-table__cell">Giovanni Rovelli</div>
</div>
</div>
</section>
<section class="sect3">
<div class="b-table">
<div class="b-table__row">
<div class="b-table__header b-table__cell--half-wide">Company</div>
<div class="b-table__header b-table__cell--half-wide">Contact</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Alfreds Futterkiste</div>
<div class="b-table__cell">Maria Anders</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Centro comercial Moctezuma</div>
<div class="b-table__cell">Francisco Chang</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Ernst Handel</div>
<div class="b-table__cell">Roland Mendel</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Island Trading</div>
<div class="b-table__cell">Helen Bennett</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Laughing Bacchus Winecellars</div>
<div class="b-table__cell">Yoshi Tannamuri</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Magazzini Alimentari Riuniti</div>
<div class="b-table__cell">Giovanni Rovelli</div>
</div>
</div>
</section>
I can't get tables 100% width of page,
how to properly set margin-top different for every table with BEM,
.sect1 .sect2 .sect3 - are they BEM blocks and should have b- class prefix, maybe for margin-top,
3a. what methods do you use to set many different margins between repeated same elements,
is border and color should be modificators when all elements have the same properties?
P.S. i can't use table - in mobile i need different cell order and some of cell need to be expandable.
I'm making a menu but my "Read More"s are not aligned on the same line
https://i.gyazo.com/3a9dd4d8e497b3772110edd4ac35fa76.png
Here's the HTML code for it
<div class="home-menu parallax" data-stellar-background-ratio="0.5">
<div class="container no-padding">
<div class="hm-info">
<div class="row">
<div class="col-md-4">
<h3><span>Today Deals</span>Breakfast</h3>
<h4>Pancakes with Seasonal Fruit</h4>
<div class="menu-wrapper">
<p>Maple Syrup & Icecream</p>
<span class="price">$13.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Pancakes with Maple Syrup</h4>
<div class="menu-wrapper">
<p>And Bacon</p>
<span class="price">$15.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Smoked Salmon Omelette</h4>
<div class="menu-wrapper">
<p>with Onion, Capers and Toast</p>
<span class="price">$16.95</span>
<div class="dotted-bg"></div>
</div>
<h4>French Toast</h4>
<div class="menu-wrapper">
<p>with Maple Syrup</p>
<span class="price">$15.95</span>
<div class="dotted-bg"></div>
</div>
<div class="menureadmore">
Read More
</div>
</div>
<div class="col-md-4">
<h3><span>Today Deals</span>Coffee</h3>
<div class="menu-wrapper">
<span class="price">$12.00</span>
<h4>Cappucino</h4>
</div>
<div class="menu-wrapper">
<span class="price">$3.95</span>
<h4>Flat White</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.20</span>
<h4>Latte</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.80</span>
<h4>Chai Latte</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.40</span>
<h4>Hot Chocolate</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.55</span>
<h4>Hot Mocha</h4>
</div>
<div class="menureadmore" >
Read More
</div>
</div>
<div class="col-md-4">
<h3><span>Today Deals</span>Lunch</h3>
<h4>Beef Lasagne</h4>
<div class="menu-wrapper">
<p>With Salad</p>
<span class="price">$16.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Fabulous Thai Chicken Patties</h4>
<div class="menu-wrapper">
<p>with Salad (Gluten Free)</p>
<span class="price">$15.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Sensational Fillet Steak</h4>
<div class="menu-wrapper">
<p>Salad & Chips.</p>
<span class="price">$21.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Roasted Vegetable Rosti Stack</h4>
<div class="menu-wrapper">
<p>(Gluten Free) with Salad</p>
<span class="price">$16.95</span>
<div class="dotted-bg"></div>
</div>
<div class="menureadmore">
Read More
</div>
</div>
</div>
</div>
</div>
</div>
And CSS
.menu-wrapper .price
{
float: right;
padding-left: 10px;
line-height: 19.8px;
margin: 5px 0px;
background: #f7f3e8;
font-weight: 700;
font-size: 15px;
color: #d80702;
font-family: Lato;
position: relative;
z-index: 11;
}
.menureadmore{
text-align:center;
font-weight:700;
font-size: 16px;
}
How do i align those "Read More"s so they are all aligned vertically?
Thanks
Bootstrap grid system is for row layouts and so the row that contains read more , that row should be enclosed in a div with class of row and then you can give them cols and they will align perfectly
give position fix with bottom 0 or whatever you want (can also try with potion absolute)
I am new in Bootstrap 3.
I am trying to create a customized list in Bootstrap 3.
What I have done is-
HTML-
<ul class="list-group">
<li class="list-group-item" id="baal">
<div class="inline" style="width : 10%;">
1
</div>
<div class="inline" style="width : 10%;">
2
</div>
<div class="inline nopadding" style="width : 60%">
<div>
name
</div>
<div>
<div class="inline" style="width : 33%;">
31
</div>
<div class="inline" style="width : 33%;">
32
</div>
<div class="inline" style="width : 33%;">
33
</div>
</div>
<div>
XXXX
</div>
</div>
<div class="inline" style="width : 10%;">
4
</div>
<div class="inline" style="width : 10%;">
5
</div>
</li>
<li class="list-group-item">Music</li>
<li class="list-group-item">Videos</li>
</ul>
CSS-
div.inline
{
float:left;
overflow: auto;
}
li.list-group-item
{
min-height: 100px;
vertical-align : center;
}
And getting a list like this-
But I want to have the inner items vertically aligned.
So I want to have a output like it-
Can anyone help me please?
Thanks in advance for helping.
This lends itself to using a sub-menu rather than divs. See -
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
li.list-group-item {
min-height: 100px;
vertical-align: center;
}
.sub li {
display: inline-block;
vertical-align: middle;
text-align: center;
width: 10%;
}
<ul class="list-group">
<li class="list-group-item" id="baal">
<ul class="sub">
<li class="inline">1</li>
<li class="inline">2</li>
<li class="inline">
<p>name</p>
<p>31</p>
<p>XXXX</p>
</li>
<li class="inline">32</li>
<li class="inline">33</li>
<li class="inline">4</li>
<li class="inline">5</li>
</ul>
</li>
<li class="list-group-item">Music</li>
<li class="list-group-item">Videos</li>
</ul>
Use the grid system, probably worth noting however that this will only work with up to 12 records.
<div class="container">
<div class="row">
<div class="col-lg-1 col-lg-offset-2">
Name
</div>
</div>
<div class="row">
<div class="col-lg-1">
1
</div>
<div class="col-lg-1">
2
</div>
<div class="col-lg-1">
3
</div>
<div class="col-lg-1">
4
</div>
<div class="col-lg-1">
5
</div>
<div class="col-lg-1">
6
</div>
<div class="col-lg-1">
7
</div>
</div>
<div class="row">
<div class="col-lg-1 col-lg-offset-2">
xxxx
</div>
</div>
</div>
produces:
if you want to use "vertical-align", you should add "display: table-cell" to the .list-group-item class
I've got such header on the page
But I want to align it like this
How to do that? My html code looks like this
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script>
$(function() {
$("#mytab a:last").tab("show")
});
</script>
<style>
.blackie {
background: black;
color: white;
}
.header {
font-size: 25px;
}
.column {
text-align: center;
}
.line {
border-right: 1px solid white;
}
</style>
</head>
<body>
<div class="row blackie">
<div class="col-md-1">
<img src="eng.png" width="40px" height="40px"/>
</div>
<div class="col-md-2 header">Admin</div>
<div class="col-md-1 col-md-offset-3">
<span class="line"></span>
</div>
<div class="col-md-2">
email
</div>
<div class="col-md-1">
<span class="line"></span>
</div>
<div class="col-md-1 column">
<span class="logout">
Log out
</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs" role="tablist" id="mytab">
<li class="active">Liabilities</li>
<li>Events</li>
<li>Reports</li>
<li>Admin</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="tab-content">
<div id="tab1" class="tab-pane active">
<p>Liabilities</p>
</div>
<div id="tab2" class="tab-pane">
<p>Events</p>
</div>
<div id="tab3" class="tab-pane">
<p>Reports</p>
</div>
<div id="tab4" class="tab-pane">
<p>Admin</p>
</div>
</div>
</div>
</div>
</body>
</html>
Here you are http://jsfiddle.net/7ky948j3/2/embedded/result/
You have the problem with padding, every col-md class has padding left nad right 15px, the image in the first col is smaller than the width of the col-md-1 class so it pushes the admi further to the right. If you add the image and Admin in the same col-md the problem will be fixed
<div class="col-md-3 header">
<img src="eng.png" width="40px" height="40px" /> Admin
</div>
Use CSS Pseudo classes which makes your work easy. here your output
use first-child Pseudo class for these need
here the html
<div class="row blackie">
<div class="col-md-1 col-sm-1">
<img src="eng.png" width="40px" height="40px"/>
</div>
<div class="col-md-11 col-sm-11 col-xs-11"> <!-- cols depends upon ur nees" -->
<ul class="main-head">
<li>
Admin
</li>
<li>
Email
</li>
<li>
logout
</li>
</ul>
</div>
</div>
and the css
ul.main-head{
display:inline-block;
width:100%;
padding:0px;
margin:0px;
vertical-align:middle;
}
ul.main-head:after{
clear:both;
content:" " ;
display:table;
}
ul.main-head li{
float:right; //floats every element to right side
text-align:right;
list-style:none;
}
ul.main-head li:first-child{
float:left; //make the first element to float left
}
ul.main-head li a{
color:#fff;
}
and line-heights and left right margins as your need to 'li' of the topbar for better results.