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>
Related
I have this div i want to center on my page as shown in the code bellow, the problem is that i am trying to add "class="center"" to each div but i cant center the whole box, anyone know why it wont center?
<div style="text-align: center;" class="pricing-table">
<?php foreach ($days AS $k => $day): ?>
<div class="col-md-5ths col-xs-6">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="text-center"><strong><?php echo UCWords(t('BUY', 'BUY')); ?></strong><br/><?php echo UCWords(t('SUBDOMAIN', 'SUBDOMAIN')); ?></h3>
</div>
<div class="panel-body text-center">
<p class="lead total-price" style="font-size:40px"><strong><?php echo SITE_CONFIG_COST_CURRENCY_SYMBOL; ?><?php echo number_format(str_replace(",", "", constant('SITE_CONFIG_COST_FOR_' . $day . '_DAYS_PREMIUM')), 2); ?></strong></p>
<p class="lead price-per-day" style="font-size:16px">
</div>
<ul class="list-group list-group-flush text-center">
<li class="list-group-item"><i class="fa fa-lock"></i> <?php echo UCWords(t('secure_payment', 'secure payment')); ?></li>
<li class="list-group-item"><i class="fa fa-eye-slash"></i> <?php echo UCWords(t('safe_and_anonymous', '100% Safe & Anonymous')); ?></li>
</ul>
<div class="panel-footer">
<?php
pluginHelper::outputPaymentLinks($day);
?>
</div>
</div>
</div>
<?php endforeach; ?>
<div class="clear"></div>
</div>
You can try flexbox. Something like the following code.
.center {
display: flex;
justify-content: center;
align-items: center;
}
Your code is already centered, which means the classes you have added but not included in your question are overriding your changes.
I strongly recommend that you use classes for styling and remove all inline styling (style="")as this have higher specificity causing overwrites.
<div style="text-align: center;" class="pricing-table">
<div class="col-md-5ths col-xs-6">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="text-center"><strong>BUY</strong><br/>SUBDOMAIN</h3>
</div>
<div class="panel-body text-center">
<p class="lead total-price" style="font-size:40px"><strong>SAMPLE</strong></p>
<p class="lead price-per-day" style="font-size:16px">
</div>
<ul class="list-group list-group-flush text-center">
<li class="list-group-item"><i class="fa fa-lock"></i></li>
<li class="list-group-item"><i class="fa fa-eye-slash"></i> </li>
</ul>
<div class="panel-footer">
FOOTER
</div>
</div>
</div>
</div>
MY RECOMMENDED METHOD
.pricing-table {
background: #eee;
}
.panel {
display: flex;
flex-direction: column;
align-items: center;
}
.text-center {
text-align: center;
}
.total-price {
font-size: 40px;
}
.price-per-day {
font-size: 16px;
}
<div class="pricing-table">
<div class="col-md-5ths col-xs-6">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="text-center"><strong>BUY</strong><br/>SUBDOMAIN</h3>
</div>
<div class="panel-body text-center">
<p class="lead total-price"><strong>SAMPLE</strong></p>
<p class="lead price-per-day">
</div>
<ul class="list-group list-group-flush text-center">
<li class="list-group-item"><i class="fa fa-lock"></i></li>
<li class="list-group-item"><i class="fa fa-eye-slash"></i></li>
</ul>
<div class="panel-footer">
FOOTER
</div>
</div>
</div>
</div>
<div style="text-align: center;"></div>
Or(You need to have a css document)
HTML
<link rel="stylesheet" type="text/css" href="Style.css">
<div class="center">
CSS
.center{
text-align: center;
}
How can I change the color of that part to something else? I want that to be the same color as footer color.
How can I do that?
what css or html code do I need?
I am using bootstrap 3.
already tried :
How to put black color in the bottom of the page after footer
that does not work for me.
my html of _Layout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - My ASP.NET Application</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
#Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
<div class="row">
<div class="col-md-12">
HEADER<div class="panel panel-primary">
<div class="panel-heading">Panel with panel-primary class</div>
<div class="panel-body">Panel Content</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
sidebar
<div class="panel panel-primary">
<div class="panel-heading">Panel with panel-primary class</div>
<div class="panel-body">Panel Content</div>
</div>
</div>
<div class="col-md-8">
<div class="col-md-12">
content1
#RenderBody()
</div>
<div class="col-md-12">
content2
<div class="panel panel-primary">
<div class="panel-heading">Panel with panel-primary class</div>
<div class="panel-body">Panel Content</div>
</div>
</div>
</div>
</div>
</div>
<div class="navbar navbar-static-top">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
FOOTER
<div class="panel panel-primary">
<div class="panel-heading">Panel with panel-primary class</div>
<div class="panel-body">Panel Content</div>
</div>
</div>
</div>
<hr />
<p>© #DateTime.Now.Year - My ASP.NET Application</p>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</div>
</div>
<footer class="navbar-default">
<div class="container">
<div class=”row bottom-rule”>
<div class="col-sm-4 footer-section">
<strong>Connect with Best Store</strong>
<p>Email promotions, news, and information</p>
<form class="form-inline">
<div class="form-group">
<label class="sr-only"
for="inputEmail">Email</label>
<input type="email"
class="form-control"
id="inputEmail"
placeholder="address#example.com">
</div>
<button type="submit" class="btn btn-default">Subscribe</button>
</form>
</div>
<div class="col-sm-5 footer-section">
<ul class="list-inline">
<li class="text-uppercase">Customer Service:</li>
<li>Returns</li>
<li>Privacy Policy</li>
<li>Our Guarantee</li>
<li>Shipping</li>
<li>Product Guides</li>
<li>Customer Care</li>
</ul>
<ul class="list-inline">
<li class="text-uppercase">Social Media & Articles:</li>
<li>Instagram</li>
<li>Pinterest</li>
<li>Twitter</li>
<li>Facebook</li>
<li>The Best Journal</li>
</ul>
<ul class="list-inline">
<li class="text-uppercase">Events:</li>
<li>Hangout April 30</li>
<li>Makers Faire</li>
</ul>
</div>
<div class="col-sm-3">
<address>
<strong>Best Store</strong><br>
1000 Some Fantastic Place<br>
San Francisco, CA 94103<br>
(123) 456-7890 (phone & text)<br>
Contact Us
</address>
</div>
</div>
<div class="row bottom-rule">
<div class="col-sm-12">
<nav class="navbar navbar-default navbar-footer">
<ul class="nav navbar-nav">
<li>Customer Care</li>
<li>Summer Lookbook</li>
<li>Gift Cards</li>
<li>About Best Store</li>
<li>Careers</li>
<li>Contact Us</li>
<li>The Best Journal</li>
</ul>
</nav>
</div>
</div><!-- end row -->
<div class="row leg-room">
<div class="col-md-12 text-center">
<h1 class="text-uppercase">Best Store</h1>
<p class="monospaced">
©2016 Best Store Company Inc.
<span class="text-uppercase">All Rights Reserved</span>
</p>
</div>
</div><!-- end row -->
</div><!-- end container -->
</footer>
</body>
</html>
Site.css:
body {
padding-top: 50px;
padding-bottom: 20px;
}
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
/* my */
.bottom-rule {
border-bottom: 1px solid lightgray;
}
footer {
padding-top: 20px;
border-top: 10px solid #332e20;
background-color: white;
}
.footer-section {
margin-bottom: 20px;
padding-bottom: 20px;
border-bottom: 1px solid lightgray;
}
#media (min-width: 768px) {
.footer-section {
margin-bottom: 0;
padding-bottom: 0;
border-bottom: none;
}
}
footer .list-inline li:not(:first-child):not(:last-child) {
border-right: 1px solid lightgray;
}
.navbar-footer {
background-color: inherit;
border-radius: 0;
border: none;
}
.navbar-footer {
margin-bottom: 0;
text-align: center;
}
footer .navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.leg-room { margin-bottom: 20px; padding-bottom: 20px; }
.monospaced { font-family: 'Ubuntu Mono', monospaced ; }
using visual studio 2015.
PS: I don't want to change the color of the background of the body to black! – user2548663 7 secs ago
Try setting the background color of the body to black:
In your css change:
body {
padding-top: 50px;
padding-bottom: 20px;
background: #000;
}
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
My pen: http://codepen.io/helloworld/pen/yyoJGR
Why is the white separater and the list-grouping flowing through the divs or the parent row?
<div class="container columnStyle">
<div class="row">
<div class="row-same-height">
<div class="col-xs-3 col-xs-height">
<img class="img-responsive" src="http://s7.postimg.org/agarkavmj/whoiswho.png"></img>
</div>
<div class="col-xs-9 col-xs-height" >
<div class="container">
<div class="row">
<div class="page-header">
<h1>Who is who
<p>
<small>Organization & Processes</small>
</p>
</h1>
</div>
</div>
</div>
<div class="container">
<div class="row">
<ul class="list-group">
<li class="list-group-item">Org Charts </li>
<li class="list-group-item">GAM / KAM Charts</li>
<li class="list-group-item">Process flow</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
.columnStyle{
background: #006AB3;
}
Because you use the class .containermultiple times.
This class has a fixed width of 1170px;
.container {
width: 1170px;
}
you should have only 1 .containerfor the wrapper and then, inside of it, remove the other .container and just use .row
See it in action : http://codepen.io/anon/pen/ogeLRb
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.