Twitter Bootstrap fixed footer on mobile devices - html

I have this page that has a fixed footer and header http://magician-bombs-84382.bitballoon.com/
On the footer, I have 4 buttons but the buttons align vertically when the width resizes to less than that of large screens. I am making a page to fit mobile device within this range of media queries
/* Small Devices, Tablets */
#media only screen and (max-width : 768px) {
}
/* Extra Small Devices, Phones */
#media only screen and (max-width : 480px) {
}
/* Custom, iPhone Retina */
#media only screen and (max-width : 320px) {
}
The app I'm making will be locked to portrait view, so I'm not thinking of ever accessing the page on large screens.
After looking at the bootstrap.css file, I cannot seem to pinpoint the code responsible for arranging the buttons vertically instead of horizontally following the col-md-3 order available inside the class row.
How can I arrange the buttons horizontally? Removing the position: absolute for footer does not seem to solve it.
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
background-color: #f5f5f5;
}

Use .col-xs-3, it won't break on extra small screens.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-xs-3">
<button class="btn btn-primary">One</button>
</div>
<div class="col-xs-3">
<button class="btn btn-primary">One</button>
</div>
<div class="col-xs-3">
<button class="btn btn-primary">One</button>
</div>
<div class="col-xs-3">
<button class="btn btn-primary">One</button>
</div>
</div>
</div>
</footer>

It works fine and buttons don't hide also.
Fiddle demo
.footer {
bottom: 0;
width: 100%;
background-color: #f5f5f5;
}

Related

How to adjust margin for small screens in Bootstrap 4?

I am trying different things to adjust the margin left for mobile (different)screen size. I am setting margin according to medium screen size using margin-left. And want to adjust for small screen size. Generally which method is useful and papular. Nothing is working in my case.What is wrong?
Can someone explain it with example. I am able to adjust screen size for column grid. But heading and header and footer is the issue. If I give heading and make it horizontal-align using margin left. How to change it for different size screen? What is wrong?
1)Do I need to add different style tags for each of them(mobile and medium size using media query. It is not working.)
2)I trying to add class visible-xs and add mobile-margin (h1 view on mobile)
3)Add bootstrap utility class (h1 Utility class)
<script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- font awsome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- font awsome -->
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
</script>
<style>
.read{
width:300px;
height:70px;
border-radius: 40px;
background-color: darkgoldenrod;
padding-left: 50px;
padding-top: 8px;
margin-left: 400px;
margin-top: 100px;
}
.learn{
width:300px;
height:70px;
border-radius: 40px;
background-color: darkgoldenrod;
padding-left: 50px;
padding-top: 8px;
/* margin-left: 400px;*/
/* margin-top: 300px;*/
}
.mobile{
width:400px;
height:70px;
border-radius: 40px;
background-color: darkgoldenrod;
padding-left: 100px;
}
.mobile-margin{
margin-left: 50px;;
}
#media only screen and (min-width : 320px) {
margin-left: 50px;
}
#media only screen and (min-width : 768px) {
margin-left: 400px;
}
</style>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1 class="read">Read more</h1>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12 ml-md-4 ml-sm-1">
<h1 class="learn">Utility Class</h1>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="mobile-margin visible-xs">
<h1 class="mobile">view on mobile</h1>
</div>
</div>
</div>
</body>
You can try Bootstrap classes to adjust according to the screen sizes. First set a default (mobile) and then change using md or lg:
<div class="row">
<div class="col-md-3 ml-0 ml-lg-5">Margin Test</div>
<div class="col-md-3 ml-0 ml-lg-3">Margin Test</div>
</div>
margin-left is set to 0 for mobile screens and margin-left is set to 5 for large screens
I give you an example of a heading H1 element.
First make sure to add bootstrap css link correctly to your page.
In bootstrap you can use the m class for margin and the p class for padding. In addition you can optionally set the side on which you want to apply margin or padding. Use ml for example to set margin left. You can give it a value between 0 and 5. For example, ml-3. You can also specify multiple values for multiple screen sizes as shown in the below example:
<h1 class="ml-5 ml-md-3 ml-lg-0">Header Text</h1>
In this example, the heading element will have a margin of 5, it will change to 3 when screen size reaches medium and it will change to 0 when screen size reaches large.
All you have to do is give the class name in the media screens.You haven't given your class name and just given margin-left
#media only screen and (min-width : 768px) {
margin-left: 400px;
}
You can specify the name like this
#media only screen and (min-width: 320px) {
.read {
margin-left: 50px;
}
}
#media only screen and (min-width: 768px) {
.read {
margin-left: 400px;
}
}
You can center the heading through
<h4 class="text-center">
<h4 class="text-lg-center">h4: centered in large screen and centered in med/smaller</h4>
<h4 class="text-md-center">h4: centered in medium/large screen and centered in smaller</h4>
<h4 class="text-sm-center">h4: centered in small/medium/large except extra small</h4>
and for buttons centering
<div class="col text-center">
<button class="btn btn-default">Centered button</button>
</div>

Responsive footer with a few images in divs

I have a Wordpress site. I have altered the footer to contain five divs with images in them.
This is the html code for the footer:
<footer class="site-footer">
<div class="table">
<div class="logo-gallery">
<div class="logo">
<img src="image_url">
</div>
<div class="logo">
<img src="image_url">
</div>
<div class="logo">
<img src="image_url">
</div>
<div class="logo">
<img src="image_url">
</div>
<div class="logo">
<img src="image_url">
</div><!-- .logo -->
</div><!-- .logo-gallery -->
</div><!-- .table -->
</footer>
For css I came up with this:
/* Footer */
.site-footer {
background-color: #e8e5ce;
/*min-height: 180px;*/
}
.site-footer .table {
display: table;
width: 80%;
margin: 0 auto;
}
.site-footer .logo-gallery {
display: table-row;
}
.site-footer .logo {
display: table-cell;
}
On a desktop computer the images now show as I would like them to:
1. they take up to 80% of the width (so that they are closer to eachother)
2. they are (as a group) placed at the center of the screen horizontally.
I want to make the images fit a smaller screen (a cell phone or tablet) - right now I get a horizontal scroll bar when I try to downsize the browser window and the images are beyong the right edge of the window (I haven't checked this code with a phone yet).
On the smaller screen I would like them either to get smaller to fit the width (all five) or appear underneath eachother (with the background color stretched underneath).
I also have a second version of css. Here, the problem is that the images clump up when downsizing the browser window (and also on the phone: check here: http://npozp.pl/)
/* Footer */
.site-footer {
background-color: #e8e5ce;
min-height: 180px;
}
.site-footer .logo-gallery {
margin: auto;
width: 70%;
}
.site-footer .logo {
float: left;
width: 20%;
height: auto;
padding: 30px 15px;
}
I am looking for a way to do this, it can be one of the above codes fix or please suggest an approach that I could take.
Thanks for reading! :-)
Please consider using media queries so that you can manipulate your layout using the pixel size of the device.
Your css adjustments should look like:
#media only screen
and (min-device-width: 320px)
and (max-device-width: 480px)
and (-webkit-min-device-pixel-ratio: 2) {
.site-footer .logo {
width: 100%;
}
}
As you can see the mix and max device width values can be changed and you can add multiple media queries to get the best out of your layout.

Issue when trying to apply a #media query with Bootstrap

I'm trying to apply a #media query so when the max-width reach 991px a padding-left will be added to the class, but nothing happens when the max-width reach 991px and the main of the page start to wrap under the aside, I'm using bootstrap and here is a part of the Code :
CSS
#media(max-width : 991px) {
.mainIcon {
padding-left: 47px;
}
}
HTML
<section class="mainin">
<div class="container-fixed mainIcon">
<div class="row mainFoto">
<div class="col-md-4">
<img src="images/code_big.png" alt="">
<a class="boutonCode">Code</a>
</div>
<div class="col-md-4">
<img src="images/tutoriel_big.png" alt="">
<a class="boutonTutoriel">Tutoriels</a>
</div>
<div class="col-md-4">
<img src="images/foucha_big.png" alt="">
<a class="boutonfoucha">PROJECTS</a>
</div>
</div>
<header class="globalTitle">
<h1 class="title">Turn Your Brean <span>On</span></h1>
<h2 class="subtitle">design the future</h2>
</header>
</div>
</section>
LIVE DEMO
when i inspect the page and try to reduce the width of the browser once he is less than 991px i see that the padding-left is not applied , i can't figure out how to fix this !
The issue appears to be that you're calling your media query at the top of the page but the regular styles for .mainIcon below it. This is causing the media query to be overwritten by the normal styles which would explain the adjusted padding-left being crossed out when you expect the element. A good rule of thumb is to always include your media queries below your other CSS (or at least under the class/id/etc. you're looking to change).
try:
.mainIcon {
width: 99%;
padding-top: 14%;
padding-left: 20%;
}
#media (max-width: 991px) {
.mainIcon {
padding-left: 47px;
}
}
#media only screen and (max-width: 991px)
{
.mainIcon {
padding-left: 47px;
}
}
or use !important
padding-left: 47px !important;

Bootstrap - How to ensure white space on far left and far right on mobile

Can anyone tell me how to ensure I get white space/margin on the left hand side and right hand side when the page is viewed on a mobile phone?
My CSS is:
#maxCostSlider {
max-width:304px;
width:304px;
padding:0px;
margin-left:-6px;
}
#media (max-width: 480px) {
#maxCostSlider,#sliderScale {
margin-left: 20px;
margin-right: 20px;
}
}
HTML is:
<div class="container-fluid">
<div class="row">
<div class="col-md-offset-4 col-md-4">
<img id="sliderScale" src="/assets/img/price slider 1.png" alt="" class="img-responsive" />
</div>
</div>
<div class="row text-center">
<div class="col-md-offset-4 col-md-4">
<input id="maxCost" data-slider-id='maxCostSlider' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="10" data-slider-value="40" />
</div>
</div>
</div>
This all looks good on a desktop and an iPad but when viewed on an iPhone the bootstrap-slider widget spans the entire width of the device. I would like to ensure there is always a margin of at least 20px either side of the two rows. Ideally the bootstrap-slider would scale to fit.
Hard to tell without know the exact slider component you are using, but adding this to your CSS should work:
#maxCostSlider {
margin-left: 20px;
margin-right: 20px;
}
However if you only want that to happen at mobile width, wrap it in a media query:
#media (max-width: 480px) {
#maxCostSlider {
margin-left: 20px;
margin-right: 20px;
}
}
For small device(sm) and extra small device (xs) you can call them separately.
<div class="col-sm-offset-1 col-xs-offset-1 col-md-offset-4 col-md-4"></div>
And another way you can do this by css.
#media (min-width: 240px) and (max-width: 480px) {
#max-cost {
padding-left: 20px;
padding-right: 20px;
}
}

automatically resizing div containers CSS

I have a webpage with 2 columns with a width of 50% and a minimum width of 500px. Now what I want to know is how to get them to resize so that when the 2nd column repositions to underneath the first, the first column resizes to fill the entire page. I can't get my head around it and any help would be much appreciated. Below is the basic code:
html:
<div class="column">
<div id="item-1">
##
</div>
</div>
<div class="column">
<div id="item-2">
##
</div>
</div>
css:
.column{
width:50%;
min-width:500px;
float:left;
}
CSS3 media queries
#media screen and (max-width: 1000px) {
.column { width: 100%; float: none; }
}
Tweak that and you should get what you want.
You can do that with a media query:
#media all and (max-width:1000px) {
.column {width:100%;}
}