Bootstrap Mobile Vertical Spacing - html

I'm using Twitter's Bootstrap to design a website but i'm finding problems to control the vertical spacing of the website on mobile view because the elements are either sticking or too far apart when switched to mobile view.
is there anything that boostrap offers to increase or decrease the spacing, such as col-xx-offset-# for the horizontal gapping?
Or is there any other standard method to control this?
Code Example with inline style:
https://jsfiddle.net/6e513k5o/
<div class="container">
<div>
<div style="color: #555;border: 3px solid #ed008c;border-radius: 4px; padding:10px" class="col-md-offset-2 col-md-3">
<img class="img-responsive" style="margin:auto" src="http://placehold.it/231x213">
</div>
<div style="color: #555;border: 3px solid #ed008c;border-radius: 4px; padding:10px;margin-top:100px;margin-left:-3px;" class="col-md-3">
<div style="text-align:center">
<label>
Mr. John Doe
</label>
<br>
<p>
CEO
</p>
</div>
</div>
</div>
</div>

use <div class="row"> after <div class="container">

The good thing about bootstrap is that you can customize it as per your need.
Please add a custom margin for columns. Please find the updated fiddle.
https://jsfiddle.net/6e513k5o/6/
HTML
<div class="container">
<div class="row">
<div class="col-md-offset-2 col-md-3 custom-class">
<img class="img-responsive" style="margin:auto" src="http://placehold.it/231x213">
</div>
<div class="col-md-3 custom-class">
<div style="text-align:center">
<label>
Mr. John Doe
</label>
<br>
<p>
CEO
</p>
</div>
</div>
</div>
</div>
CSS
.custom-class {
color: #555;
border: 3px solid #ed008c;
border-radius: 4px;
padding: 10px;
margin-bottom: 10px;
}

Related

Cards that I created in Bootstrap 4 are not responsive when changing screens

I created some Cards using bootstrap, html and css. Unfortunately, when I change the size of the screen the cards do not adjust accordingly.
This is how they look right now before changing the size.
When I go to inspect and switch it to ipad, it looks like this:
I tried using a media query in my css folder to solve this, but no luck. Can someone tell me what I am doing wrong? EDIT: Ideally, I would like to have one card on top of another when changing the screen size. I would also like to have the spacing in between the cards as well.
<div class="col-md-4">
<div class="ScoreCard">
<div>
<h3 style="background-color:#item.TitleColor"> #item.ReportName - #item.TitleColor </h3>
</div>
<div class="col-lg-4">
<div style="font-weight:bold; margin-top:35px;">
<h1>GrossAmountDue</h1>
</div>
</div>
<div class="col-lg-2" style="margin-top:35px;">
if (Flag == 1)
{
<i class="fas fa-circle" style="font-size:30px; color:red; margin-left:15px;"></i>
}
</div>
<div class="col-lg-6">
<div>
<p style="font-size:20px; margin-left: 25px;">Audited </p>
<p style="font-size:20px; margin-left: 25px;">Packages: Will go here</p>
<p style="font-size:20px; margin-left: 25px;">Transactions will go here</p>
<p style="font-size:20px;"Icon will go here</p>
</div>
</div>
<div class="row">
<div class="col-lg-12" style="margin-top: 5px;">
<p style="margin-left:17px;">Text Here</p>
</div>
</div>
</div>
</div>
//CSS
<style>
.ScoreCard {
background-color: orange;
width: 500px;
min-height: 200px;
border: 15px black;
}
##media screen and (max-width: 100px){
.col{
width: 50%;
}
}
</style>
You have to wrap your cols in a row like this:
<div class="row">
<div class="col-md-12 col-lg-4">
<div class="card">...</div>
</div>
<div class="col-md-12 col-lg-4">
<div class="card">...</div>
</div>
<div class="col-md-12 col-lg-4">
<div class="card">...</div>
</div>
</div>
In this way, when you have a screen equal or less of md, contents of cols goes one on top of another, but when screen is lg or higher, you have 3 cols in a row.
INFO
In your media query you are changing the col class, when instead you are using col-md-4

Suggestion how to make a grid in banner

On this page:(I just set a red and green border to make it more clear)
I have a picture of a book, which need to be in the left side where the black border is:
I have tried to build up the banner with the code below. But I cannot figure out how I can set a div tag that would fit the left side where the black border is.
Does anybody have an advice on how I could do that?. The code there is until now is this:
<div class="top-area" style="border: 4px solid red;">
<div class="container" style="border: 4px solid green;">
#if (!string.IsNullOrEmpty(headerText))
{
if (pageAlias == "Blog")
{
<h1 class="header-xl center">
#Html.Raw(headerText)
</h1>
}
else
{
<p class="header-xl center">
#Html.Raw(headerText)
</p>
}
}
#if (CurrentPage.HasValue("imageTeaserText"))
{
<p class="sub-header center">
#Html.Raw(CurrentPage.imageTeaserText)
</p>
}
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="container-fluid">
<div class="row">
<div class="col-md-12 main-content" id="main-content">
<div class="row">
<div class="col-lg-12">
#CurrentPage.GetGridHtml("inovoGrid")
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here's an example on plunkr using the bootstrap columns to keep elements aligned on either side of your title. Bootstrap aligns its grid based on 12 columns. I've only added support for small density screens via col-sm-x, you should experiment with the other densities.

image between 2 inline-table divs - doesn't work with bootstrap

I'm working on some trading ingame items site, that's not important here.
My actual code is:
<div class="trade">
<h6><strong>RaiZeN</strong> wants to trade: (5 minutes ago)</h6>
<div class="items-holder">
<div class="item-img" style="background-image:url('http://steamcommunity-a.akamaihd.net/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpot7HxfDhjxszJemkV08u_mpSOhcjnI7TDglRc7cF4n-T--Y3nj1H6-hBrMW_3LIOWdlU_MlGDqwO6wrvq15C6vp-bnHY36SAm4XbYl0SwhgYMMLJqUag1Og/360fx360f');">
<div class="item-rarity">Field-Tested</div>
<div class="pink"></div>
</div>
<div class="item-img" style="background-image:url('http://steamcommunity-a.akamaihd.net/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpot7HxfDhjxszJemkV08u_mpSOhcjnI7TDglRc7cF4n-T--Y3nj1H6-hBrMW_3LIOWdlU_MlGDqwO6wrvq15C6vp-bnHY36SAm4XbYl0SwhgYMMLJqUag1Og/360fx360f');">
<div class="item-rarity">Field-Tested</div>
<div class="pink"></div>
</div>
</div>
<div class="arrow">
<img src="http://i.imgur.com/dusRcnt.png" />
</div>
<div class="items-holder">
<div class="item-img" style="background-image:url('http://steamcommunity-a.akamaihd.net/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpot7HxfDhjxszJemkV086jloKOhcj8NrrHj1Rd6dd2j6fA9ImniQex_UQ_NT-nJtKRJgU3aFHY_Vm-ybrqjMO56Z3OnXE27HIq-z-DyAtSAyL7/360fx360f');">
<span class="item-rarity">Battle-Scared</span>
<div class="red"></div>
</div>
</div>
</div>
JSFIDDLE
As you can see, the arrow is not at same height as rest. But, if I will remove bootstrap (remove first html line), it works just fine. Problem is, I need to use bootstrap on my site. How can I fix that?
check this - https://jsfiddle.net/7curr49y/1/
the changes i made are these -
.items-holder
{
background-color: #E7E7E7;
border-radius: 4px;
padding: 10px;
display: inline-block;
border-collapse: separate;
border-spacing: 10px 0px;
vertical-align:middle;
}
changed "inline-table" to "inline-block" and added "vertical-align:middle".
hope that helps!

Layout using Bootstrap and Div

I'm trying to build a company intranet page, with a "grid" style layout. In the past I've used tables, however I know that these are extremely problematic when used for layouts, hence I am attempting to construct the layout using bootstrap and Divs - however it's proving problematic.
Ultimately what I'm trying to achieve in the top right hand corner of the page is:
However what I'm ACTUALLY rendering is the following:
Ignoring the fact that the weather data is a little more expanded, I'm struggling to get the desired result and am really tempted to revert back to tables to get this thing to line up!
Here is the code that I am using on the main template page:
<div class="row">
<div class="col-sm-3">.col-sm-4</div>
<div class="col-sm-4">.col-sm-4</div>
<div class="col-sm-5">
<img src="~/Content/Images/companylogo.png" style="float: right; padding-right: 15px; padding-bottom:25px;"/>
<div style="padding-top:25px; border-bottom: 1px solid black;">
<div id="weatherDiv" style="float:left;"></div>
<div id="dateDiv" style="float:right; padding-right:10px; vertical-align: bottom;"></div>
</div>
</div>
</div>
And then upon page load, the two DIVs (weatherDiv & dateDiv) are filled in using AJAX:
WeatherDiv:
<div id="weatherDiv" style="float:left;">
<link href="/Content/css/weather-icons.css" rel="stylesheet">
<link href="/Content/css/weather-icons-wind.css" rel="stylesheet">
<div>
<ul style="list-style: none; margin-left: 0px; padding-left:0px;">
<li>Brisbane - Hot and sunny - 32c <i class="wi wi-day-sunny"></i></li>
<li>Melbourne - Early shower or two - 17c <i class="wi wi-showers"></i></li>
</ul>
</div>
</div>
DateDiv:
<div id="dateDiv" style="float:right; padding-right:10px; vertical-align: bottom;">
<h4>Friday, 20 November 2015</h4>
</div>
I understand totally that my use of CSS, Bootstrap & Divs are almost laughable, however the above is a result of hours of trying and trying!
Any help is much appreciated.
It's hard to be exactly sure how you want this layout to work on mobile. But here is a jsfiddle I've created that could help.
https://jsfiddle.net/2dqqajs1/
body {
min-width: 320px;
}
.text-right img{
display: inline-block;
}
/*extra small screens only*/
#media (max-width: 767px) {
#weatherDiv{
text-align: right;
}
}
hr {
margin: 0;
border-top: solid 2px #e0e0e0;
}
<div class="container">
<div class="row">
<div class="col-xs-4"></div>
<div class="col-xs-8">
<div class="row">
<div class="col-xs-12 text-right">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=CompanyLogo&w=400&h=100" class="img-responsive" />
</div>
</div>
<div class="row">
<div id="dateDiv" class="col-xs-12 col-sm-5 col-sm-push-7 text-right">
<h4>Friday</span>, 20 Nov<span class="hidden-xs hidden-sm">ember</span> 2015</h4>
</div>
<div id="weatherDiv" class="col-xs-12 col-sm-7 col-sm-pull-5">
<ul style="list-style: none; margin-left: 0px; padding-left:0px;">
<li>Bris<span class="hidden-sm">bane</span> <span class="hidden-xs">- Hot and sunny </span>- 32c <i class="fa fa-sun-o"></i></li>
<li>Melb<span class="hidden-sm">ourne</span> <span class="hidden-xs">- Early shower or two </span>- 17c <i class="fa fa-cloud"></i></li>
</ul>
</div>
<div class="col-xs-12"><hr/></div>
</div>
</div>
</div>
</div>

CSS: Border-top won't work properly

I'm using Bootstrap and I'm trying to fix the border. It will only appear above the text because of the pull right and left. What should I do to make it appear over the whole line?
HTML
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="pull-left">
<footer class="footer"><p>text1</p></footer>
</div>
</div>
<div class="col-md-6">
<div class="pull-right">
<footer class="footer"><p>text2</p></footer>
</div>
</div>
</div>
</div>
CSS
.footer {
padding-top: 19px;
margin-top: 7px;
color: #777;
border-top: 1px solid #e5e5e5;
}
You can't without changing your markup.
It makes more sense to give your footer row another fitting class: footer-row and apply styles to that instead:
HTML
<div class="container">
<div class="row footer-row">
<div class="col-md-6">
<div class="pull-left">
<footer class="footer"><p>text1</p></footer>
</div>
</div>
<div class="col-md-6">
<div class="pull-right">
<footer class="footer"><p>text2</p></footer>
</div>
</div>
</div>
</div>
CSS
.footer-row {
padding-top: 19px;
margin-top: 7px;
color: #777;
border-top: 1px solid #e5e5e5;
}
Bootply
Change your code like this:
<footer class="container">
<div class="row">
<div class="col-md-6">
<div class="pull-left">
<p>text1</p>
</div>
</div>
<div class="col-md-6">
<div class="pull-right">
<p>text2</p>
</div>
</div>
</div>
</footer>
Basically, you get rid of your double footer element and apply the container class to the footer element so it expands the whole width and remains as a single footer when resized
This solves your issue AND is semantically correct since you won't have 2 footer elements
I have added a Bootply so you can see how it works
If indeed you want text 1 and text two to take up half of the div each, try putting the footer tag as a whole across all columns as one element, then text one and text 2 nested in two divs with columns of 6.