I have two columns. Desktop:
Mobile:
This is expected behavior, but I want the column on the left "Browse Programs" to show up on top of the left column, not below it. I've tried a few different things, including reversing the order of columns in HTML and using "float-left" (which works, but not a great solution). I've also used col-md-pull and col-md-push but neither is working.
For what it's worth, I'm not using bootstraps 4 and I'd prefer to keep that as is for now.
Place the blocks inside the layout in the order in which they should go on the mobile.
Introduction: Bootstrap is developed mobile first, a strategy in which we optimize code for mobile devices first and then scale up components as necessary using CSS media queries.
Change their order. To do this, Bootstrap 3 provides classes of the type .col-md-push-9 and .col-md-pull-3, and Bootstrap 4 provides the order classes.
Demo for Bootstrap 3: https://codepen.io/glebkema/pen/qBONaQd
/* Demo Decorations */
.row-demo > div {
color: white;
font: bold 20px sans-serif;
padding: 9px 15px 30px;
}
.row-demo > div:first-child {
background: #69c;
}
.row-demo > div:last-child {
background: #c69;
}
<div class="container">
<div class="row row-demo">
<div class="col-md-3 col-md-push-9">Top on mobile / Right on desktop</div>
<div class="col-md-9 col-md-pull-3">Bottom on mobile / Left on desktop</div>
</div>
</div>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
Demo for Bootstrap 4: https://codepen.io/glebkema/pen/GRpZVZq
/* Demo Decorations */
.row-demo > div {
color: white;
font: bold 20px sans-serif;
padding: 9px 15px 30px;
}
.row-demo > div:first-child {
background: #69c;
}
.row-demo > div:last-child {
background: #c69;
}
<div class="container">
<div class="row row-demo">
<div class="col-md-3 order-md-last">Top on mobile / Right on desktop</div>
<div class="col-md-9 order-md-first">Bottom on mobile / Left on desktop</div>
</div>
</div>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
Related
Upgrading to Bootstrap 4, and I cannot find an answer for this issue anywhere. In order to get the Datetime Picker to work, I found this version for the .CSS and JavaScript files:
https://github.com/tempusdominus/bootstrap-4
This worked, my Datetime picker does what it should. However, if I then change the CSS file to use rem instead of px, the Datetime Picker's icon to the right is about half the height of what it should be. This is what the HTML looks like:
<div class="row">
<div class="col-4 offset-2">
<label for="date_started">Date Started:</label>
<div class="input-group date" id="datetimepicker_pos_date_start" style="width: 250px;">
<input name="date_started" id="date_started" type="text" class="form-control" />
<span class="input-group-addon">
<span class="input-group-text"><i class="fa fa-calendar"></i></span>
</span>
</div> <!-- // input-group -->
<p class="help-block">Provide the date you started this position, if known.</p>
</div> <!-- // col-4 -->
</div> <!-- // row -->
Until I changed the site to start using rem instead of px for measurements in my CSS file, the code worked flawlessly with the correct JavaScript and so on. But what did happen is that the height of the button on the right is about half what it should be.
I realize that this code does not use the new replacement in Bootstrap 4 "input-group-append", but when I tried to change it, the whole thing stopped working. I cannot find any settings I can make to get the button to be the correct height to the right of the entryarea. If I leave it like this, it works, but the button is not the correct height.
And having made a bunch of changes to my CSS file for other parts of the site, I have no idea what may be affecting this. The whole CSS file is too long to post here, but the basics at the top are here:
html
{
/* required for fixed footer */
position: relative;
min-height: 100%;
font-size: 62.5%; /* = 10px */
}
body
{
font-family: Arial, Helvetica, sans-serif;
font-size: 1.6rem; /* = 16px */
/* font-size: 16px; */
color: #000000;
background-color: #FFFFFF;
margin-top: 1.0rem; /* 10px; */
margin-left: .2rem; /* 2px; */
margin-right: .2rem; /* 2px; */
padding: .5rem; /* 5px; */
/* for fixed footer */
margin-bottom: 4.0rem; /* 40px; */
}
I am hoping someone has some experience with this, or a possible solution to it. I tried putting this into my CSS file, but it doesn't seem to have any effect at all:
.input-group-addon, input-group-text
{
height: 3.0rem !important;
font-size: 3.0rem !important;
}
I am building a login form for my web application using bootstrap for the styling. I have used the below "Meta Tag" to make the screen responsive
<meta name="viewport" content="width=device-width, initial-scale=1.0">
and multiple combinations of bootstraps col class of the grid system but to no avail.
<style>
.overlay {
/* Height & width depends on how you want to reveal the overlay (see JS below) */
height: 100%;
width: 0;
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
background-color: rgb(0,0,0); /* Black fallback color */
background-color: rgba(51, 51, 255, 0.9); /* Black w/opacity */
overflow-x: hidden; /* Disable horizontal scroll */
transition: 0.5s; /* 0.5 second transition effect to slide in or slide down the overlay (height or width, depending on reveal) */
}
/* Position the content inside the overlay */
.overlay-content {
position: relative;
top: 20%; /* 25% from the top */
width: 100%; /* 100% width */
text-align: center; /* Centered text/links */
margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
}
/* The navigation links inside the overlay */
.overlay a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block; /* Display block instead of inline */
transition: 0.3s; /* Transition effects on hover (color) */
}
/* When you mouse over the navigation links, change their color */
.overlay a:hover, .overlay a:focus {
color: #f1f1f1;
}
/* Position the close button (top right corner) */
.overlay .closebtn {
position: absolute;
}
/* When the height of the screen is less than 450 pixels, change the font-size of the links and position the close button again, so they don't overlap */
#media screen and (max-height: 450px) {
.overlay a {font-size: 20px}
.overlay .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
<div id="myNav" class="overlay">
<div class="overlay-content">
<div class="container">
<div class="row">
<div class="col-12"> // column which contains the login form code
<div id="loginform">
// login form code
</div>
<div id="signupform">
// signup form code
</div>
</div>
</div>
</div>
</div>
This is my output - Output Image
Appreciate any insight as to what I am doing wrong and how to go about this.
Thanks a ton.
Try using the class form-group rather than login form and signup form.
It may make the web form mobile responsive.
Check: Bootstrap Form Document
I am providing this as an answer because it's too much to put in a comment.
Make sure you're using <!doctype html>
In order to make sure Bootstrap 4 works correctly in Safari, use shrink-to-fit=no - see What does the shrink-to-fit viewport meta attribute do?
Use the bootstrap class for text-center instead of the HTML attribute align - see Text - Bootstrap
Since your class is always going to have col-XX-12 based on your example, just use col-12. See Grid system
As mentioned in the above example, this is a good place to use form-group - see Forms - Boostrap
Overall, please start with Introduction - Bootstrap
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="col-12 text-center"> // column which contains the login form code
<div id="loginform">
// login form code
</div>
<div id="signupform">
// signup form code
</div>
</div>
</body>
</html>
So I uploaded a question that's the same as this one, however, that got very overcrowded so I am putting up the question again in hopes of explaining my problem a bit better.
I am currently making my own website using HTML, CSS, and JavaScript with bootstrap alongside. While trying to make the site mobile friendly, I have noticed an error with how 3 of the buttons are being displayed on the screen. Basically, what I want to happen is for the three buttons to be stacked on top of each other with a gap in between each one when the web page is viewed on mobile. However, the buttons aren't displaying correctly. See the first image.
One thing that I will say, though, is that I am using the feature (not sure if it's only in Google Chrome) that when you click inspect element, you can select an option that allows you to view what the web page will look like on a mobile screen. What I'm getting at, is that I don't know if it's the code that's wrong or if Google Chrome's feature doesn't work that well.
If you do have any suggestions for applications I could use to view the HTML file on a mobile device, please let me know.
PLEASE NOTE. I HAVE ONLY GIVEN THE CODE FOR ONE OF THE BUTTONS AS THE OTHER TWO ARE BASICALLY THE SAME
#media (max-width: 767px){
.btn-block-xs {
display: block;
width: 100%;
margin-bottom: 10px;
}
}
#cheapestOption {
font-family: 'Pavanam', sans-serif;
background-color: rgba(255,255,255,0.3);
border: none;
}
#cheapestOption a {
text-decoration: none;
color: white;
}
#cheapestOption p {
font-family: 'Pavanam', sans-serif;
font-size: 50px;
}
#cheapestOption ul{
text-align: left;
font-size: 17px;
}
#cheapestOption:hover {
background-color: rgba(255, 255, 255, 0.6);
text-decoration: none;
}
<div class="container-fluid" id="grad"> <!-- Pricing Buttons -->
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4">
<button type="button" id="cheapestOption" class="btn btn-block-xs" aria-label="center Align">
<a href="pricing.html" target="_blank">
<h4>Text</h4>
<p><strong>£££</strong><span>/ £5 a month</span></p>
<ul>
<li> Text </li>
<li> Text </li>
<li> Text </li>
<li> Text </li>
</ul>
</a>
</button>
</div>
(First picture shows what it looks like on mobile) (this is what needs fixing)
(Second picture shows what it looks like on desktop) (this is fine)
You html and css are not really following the bootstrap documentation. I suggest you read more on how bootstrap works. You can simplify a lot of what you are doing and probably make things look a lot better too.
I would suggest create a button which is a link and move the text out of it. To answer your question exactly please see this jsfiddle.
I moved your html to be in the correct col class Let me know if you have anymore questions,
html
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4"><button type="button" id="cheapestOption" class="btn btn-block-xs" aria-label="center Align">
<a href="pricing.html" target="_blank">
<h4>Text</h4>
<p><strong>£££</strong><span>/ £££ a month</span></p>
<ul>
<li> Text </li>
<li> Text </li>
<li> Text </li>
<li> Text </li>
</ul>
</a>
</button></div>
<div class="col-md-4 col-sm-4 col-xs-4"> <button type="button" id="averageOption" class="btn btn-block-xs" aria-label="center Align">
<a href="pricing.html" target="_blank">
<h4>Text</h4>
<p><strong>£££</strong><span>/ £££ a month</span></p>
<ul>
<li> Text </li>
<li> Text </li>
<li> Text </li>
<li> Text </li>
</ul>
</a>
</button></div>
<div class="col-md-4 col-sm-4 col-xs-4"> <button type="button" id="expensiveOption" class="btn btn-block-xs" aria-label="center Align" disabled>
<h4>Text</h4>
<p><strong>£££</strong><span>/ £££ a month</span></p>
<p id="tempBottom"><strong>Coming Soon</strong></p>
</button></div>
</div>
</div>
CSS
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
#cheapestOption {
font-family: 'Pavanam', sans-serif;
background-color: red;
border: none;
}
#cheapestOption a {
text-decoration: none;
color: white;
}
#cheapestOption p {
font-family: 'Pavanam', sans-serif;
font-size: 1em;
}
#cheapestOption ul {
text-align: left;
font-size: 17px;
}
#cheapestOption:hover {
background-color: rgba(255, 255, 255, 0.6);
text-decoration: none;
}
#averageOption {
font-family: 'Pavanam', sans-serif;
width: 100%;
background-color: red;
border: none;
color: white;
}
#averageOption a {
text-decoration: none;
color: white;
}
#averageOption p {
font-family: 'Pavanam', sans-serif;
font-size: 1em;
}
#averageOption ul {
text-align: left;
font-size: 17px;
}
#averageOption:hover {
background-color: rgba(255, 255, 255, 0.6);
}
#expensiveOption {
font-family: 'Pavanam', sans-serif;
width: 100%;
background-color: red;
border: none;
color: white;
}
#expensiveOption a {
text-decoration: none;
color: white;
}
#expensiveOption p {
font-family: 'Pavanam', sans-serif;
font-size: 1em;
}
#expensiveOption ul {
text-align: left;
font-size: 1em;
}
To simplify this for you here are a few things to remember,
Bootstrap is built for mobile first.
Each row consist of 12 pieces, so when you tell it col-md-4 you are saying that when the browser is the width of col-md you want that space to take up 1/3 of the width of the row.
You can target each browser size by default css built into bootstrap using col-xs col-sm -col-md etc... To see the default size of each col-size check the documentation or inspect element and check the class in the DOM.
Bootstrap Grid System
If you want the col-size to stack at certain screen widths this is what you can do.
If when the screen is sm you want them to stack you could do,
<div class="row">
<div class="col-sm-12">
<p>My text here will be on this row alone.</p>
</div>
<div class="col-sm-12">
<p>My text here will be on this row alone.</p>
</div>
<div class="col-sm-12">
<p>My text here will be on this row alone.</p>
</div>
</div> <!-- end of row -->
This will stack on sm size because when the screen is the width of the sm size it will take up 12 which is the whole space. So that media query will fire off and the col will now take up the whole row.
Remeber you can stack each class as well. So if you want to make sure each col stack starting with md you could do this,
<div class="col-xs-12 col-sm-12 col-md-12 ">
Now when the browser is at each of those class target widths whatever html is in that div will take up the whole row.
Technologies:
Bootstrap 3
Less
Jade
Angular
Issue:
I'm using .col-xs-12.col-md-6 for the section.
For some reason when it should switch from .col-md-6 and .col-xs-12 should be applied so that the column can stretch the full width of the screen, the layout doesn't spread out until 743 screen width. (It should go full width at 991px or if i'm wrong atleast 767px screen width).
I have custom styling on .col-md-6 and apply 49% to the width of that class bc .col-md-5 was too small and .col-md-6 was too large to add the needed 20px margin space in between. (styling guidelines).
I removed the width: 49%; when seeing what would happen at the 992 and 768 break point and there is nothing.
It just breaks at random breakpoints.
(I've tested where it breaks for col-lg-6 and col-xl-6 or 5 .. just to test it out and it continues to break in break point areas not connected to the usual 768, 992, 1200 etc.)
I have removed styling from every place possible to see if thats effecting it ..
This is an include file and so even styling connected to the main page. (I put it back bc that wasn't the cause).
These break point additions have worked in the past I don't know whats wrong now.
My only other alternative is using media queries instead which I will try in the meantime but I am wanting to avoid that.
Update:
I reformatted the code in an entirely separate file from the project and put it in regular html and it worked fine. I copied and pasted the code at the very bottom. I removed angular and left it hard coded so that i can open in the browser quickly. I am thinking it may have something to do with the surrounding files in this project. I copied and pasted the code at the very bottom.
Jade file:
#pizza
.col-xs-12
h3 Other Shops
.col-xs-12.col-md-6(ng-repeat="other in otherShops")
.col-xs-12(ng-repeat="tag in other.tags | limitTo: 1")
img(ng-src="{{tag.sm_active_url}}")
{{tag.name}}
.col-xs-3
img(src="http://www.carlotfinance.com/assets/img/car_placeholder.jpg", alt="placeholder image")
.col-xs-8
h2
a(href="#/shops/{{shop.id}}/detail") {{ other.name }}
.glyphicon.glyphicon-road
.glyphicon.glyphicon-unchecked
p {{ other.address }}
p {{ other.phone }}
button.btn.col-xs-12.makeAppointmentBtn(type='button', ng-controller='makeAppointmentCtrl', ng-click='open()') Make Appointment
Less:
#pizza{
h3{
color: #999;
}
.col-md-6{
background-color: #ffffff;
border-radius: 8px;
margin-bottom: 50px;
padding-left: 0;
padding-right: 0;
// width: 49%;
min-height: 440px;
&:nth-child(even){
margin-right: 20px;
}
h2{
a{
color: #000;
}
a:hover{
text-decoration: none;
}
}
.col-xs-3{
margin-left: 20px;
margin-top: 30px;
img{
width: 100%;
}
}
.btn{
position: absolute;
background-color: #003366;
padding: 10px;
border-radius: 8px;
color: #fff;
bottom: 0;
left: 0;
}
.glyphicon{
color: #999;
font-size: 24px;
}
.col-xs-12{
font-size: 24px;
margin-top: 20px;
img{
margin-left: 20px;
}
}
.col-xs-8{
margin-bottom: 40px;
}
}
}
Reformatted code:
<!DOCTYPE html>
<html class="full" lang="en">
<head>
<title>Pizza</title>
<!-- Bootstrap Core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="col-xs-12 col-md-6 ng-scope">
<div class="col-xs-12">
<img ng-src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png" src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png"> Tools</div><!-- end ngRepeat: tag in other.tags | limitTo: 1 -->
<div class="col-xs-3"><img src="http://www.carlotfinance.com/assets/img/car_placeholder.jpg" alt="placeholder image"></div>
<div class="col-xs-8">
<h2>Pizza Place
<div class="glyphicon glyphicon-road"></div>
<div class="glyphicon glyphicon-unchecked"></div>
</h2>
<p>1234 M Ave, Austin, TX 27000</p>
<p>(555) 400 2800</p>
</div>
<button type="button" class="btn col-xs-12 makeAppointmentBtn ng-scope">Make Appointment</button>
</div>
<div class="col-xs-12 col-md-6 ng-scope">
<div class="col-xs-12">
<img ng-src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png" src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png"> Tools</div><!-- end ngRepeat: tag in other.tags | limitTo: 1 -->
<div class="col-xs-3"><img src="http://www.carlotfinance.com/assets/img/car_placeholder.jpg" alt="placeholder image"></div>
<div class="col-xs-8">
<h2>Pizza Place
<div class="glyphicon glyphicon-road"></div>
<div class="glyphicon glyphicon-unchecked"></div>
</h2>
<p>1234 M Ave, Austin, TX 27000</p>
<p>(555) 400 2800</p>
</div>
<button type="button" class="btn col-xs-12 makeAppointmentBtn ng-scope">Make Appointment</button>
</div>
</body>
</html>
It's mostly in the title. I am displaying products in divs on my website. On hover, I make them increase in size by applying a margin of -15px to give them a nice hover effect. When I hover over any of them, it is fine except for the right-most ones, as it pushes the products below it away into the Bootstrap row below. Here are images:
Good (hover over a middle one):
Bad (hover over the right-most one):
Here is the code:
Search results page:
<div id="search-results">
<div data-bind="template: { name: 'product-template', foreach: allProducts }"></div>
</div>
Product template:
<script type="text/html" id="product-template">
<div class="col-sm-6 col-lg-2" style="margin-top:20px; padding: 25px;">
<div class="product-item">
<div data-bind="style: { backgroundImage: 'url(\'../../the_vegan_repository/product_images/' + product.imagePath + '\')' }"
style= "height: 160px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
color: white;
background: center no-repeat;
background-size:cover;
vertical-align:bottom;">
</div>
<div style="height: 110px; padding: 10px; background: #fc4747;">
<h6 class="medium-text" data-bind="text: product.brand" style="text-transform: uppercase; color: white; margin-top:0; margin-bottom:5px;"></h6>
<h6 class="medium-text" data-bind="text: product.name" style="text-transform: uppercase; color: white; margin-bottom:5px;display: inline;"></h6>
</div>
</div>
</div>
</script>
CSS:
div.product-item:hover {
margin: -15px;
}
div.product-item {
border: 5px solid #fc4747;
border-radius: 15px;
height: 240px;
overflow: hidden;
cursor: pointer;
}
How do I stop the Bootstrap grid system from pushing the bottom row into the row lower?
on hover, I make them increase in size by applying a margin of -15px
Use transform: scale(x); instead of margin: -15px; as transforms do not affect the box-model of the element.
CSS Transforms Module Level 1:
Note: Transformations do affect the visual layout on the canvas, but have no affect on the CSS layout itself. This also means transforms do not affect results of the Element Interface Extensions getClientRects() and getBoundingClientRect(), which are specified in [CSSOM-VIEW].
If you want to move it up by a certain amount, use transform: translateY(-15px) instead of changing the margin on the div.product-item:hover class. To move it in a context that does not interrupt the rest of the document. Or you can use transform: scale(1.2) to make things bigger.
The problem is that it's actually changing the dimentions of the div when you change the margin which in turn affects others. Check out this link . It gives an example on how to give such zoom effect.
Creating a Zoom Effect on an image on hover using CSS?