Sticky footer bootstrap 4 [duplicate] - css

This question already has answers here:
Bootstrap 4 - Sticky footer - Dynamic footer height
(3 answers)
Footer in Bootstrap, that extends with content or sticks to the bottom
(3 answers)
Closed 4 years ago.
I’m trying to make a sticky footer using bootstrap 4. How do I make sure regardless of how much content it always stays at the bottom of the screen? I've looked up other answers for sticky footers and haven't been able to get it to work so I wanted to share my code. I've tried changing out the position from fixed, absolute and relative none of which work.
On another project I was able to get it to work with absolute. Does it have to do with my css for html and body?
HTML
<footer class="footer">
<!-- <div class="container-fluid"> -->
<a href="https://www.facebook.com/lucas.stahl.75">
<i class="fa fa-facebook"></i>
</a>
<a href="https://twitter.com/LucasStahl11">
<i class="fa fa-twitter"></i>
</a>
<a href="https://www.linkedin.com/in/lucasstahl">
<i class="fa fa-linkedin"></i>
</a>
<a href="https://lucasstahl.wordpress.com/">
<i class="fa fa-wordpress"></i>
</a>
<p id="copyRight">#Copyright 2018 www.lucasstahl.com</p>
<!-- </div> -->
</footer>
CSS
body,
html {
width: 100%;
height: 100%;
/* min-height: 100%;
position: relative; */
background-position: center;
background-image: url("clark.png");
background-size: cover;
}
.footer {
/* clear: both; */
/* position: absolute; */
background-color: rgb(229, 240, 136);
text-align: center;
color: rgb(175, 167, 166);
border-top: 5px solid rgb(175, 167, 166);
overflow: hidden;
padding-top: 20px;
bottom: 0;
width: 100%;
height: 100px;
}
The problem I have is that it's moving the footer depending on the size of the screen. It won't stay there all the time.

For different screens you will need to use media queries This will allow you define at each size of your screen how the footer will look.
http://getbootstrap.com/docs/4.0/examples/sticky-footer-navbar/ Is what you need by the looks of things
Look at the code I've provided jsfiddle
<footer class="footer">
<!-- <div class="container-fluid"> -->
<nav>
<li><a href="https://www.facebook.com/lucas.stahl.75">
<i class="fa fa-facebook"></i>
</a></li>
<li><a href="https://twitter.com/LucasStahl11">
<i class="fa fa-twitter"></i>
</a></li>
<li><a href="https://www.linkedin.com/in/lucasstahl">
<i class="fa fa-linkedin"></i>
</a></li>
<li><a href="https://lucasstahl.wordpress.com/">
<i class="fa fa-wordpress"></i>
</a></li>
<li id="copyRight">#Copyright 2018 www.lucasstahl.com</li>
</nav>
<!-- </div> -->
</footer>
CSS
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
background-color: yellow;
}
nav {
display: flex;
list-style: none;
}

Related

page not showing properly in firefox and explorer

The problem is, I'm trying to test my template for all the browsers, it looks fine in Chrome (I use it primarily) but it looks off in Firefox and Explorer.
I tried to use prefixes, I used auto prefix in brackets to make sure everything is as it should. in Firefox, the background is not showing, and the search bar doesn't have the correct padding that I gave it. Same thing with explorer but the search bar is fine but the background not so much.
.header {
background-image: url(images/headerimg.webp);
background-size: cover;
background-position: center;
height: 300px;
padding: 0;
margin: 0;
text-align: center;
}
.searchContainer {
float: left;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
}
.search {
padding: 7px 10px !important;
border-radius: 0 4px 4px 0;
font-size: 17px;
border: 2px solid #363a5e;
border-left: none;
width: 360px;
color: #666a8c;
margin: 1px 0 0 -3px;
background-color: #363a5e;
-webkit-transition: .2s;
transition: .2s;
}
<header class="header jumbotron" role="heading" aria-level="1">
<div class="filter">
<div class="container">
<div class="mobileOpenContainer">
<span onclick="openNav()" class="showNavSearch"><i class="fas fa-bars"></i></span>
<span onclick="openSearch()" class="showNavSearch" id="search"><i class="fas fa-search"></i></span>
</div>
<div class="logoNavContainer" role="img">
<img class="logo" src="images/Logo.svg" alt="logo">
<nav>
<ul class="navbar" role="navigation">
<a href="#">
<li class="nav">خانه</li>
</a>
<a href="#">
<li class="nav">تبلیغات</li>
</a>
<a href="#">
<li class="nav">تماس با ما</li>
</a>
<a href="#">
<li class="nav">خرید قالب</li>
</a>
</ul>
</nav>
</div>
<div class="reqSearchContainer">
<button class="request" role="button"><i class="fas fa-film"></i>درخواست انتشار</button>
<button class="request" role="button"><i class="fas fa-heart"></i>حمایت از ما</button>
<div class="searchContainer">
<label>
<input class="search" placeholder="جستوجو..." aria-label="Searchbar">
<span class="searchBtn" aria-label="Search button"><i class="fas fa-search"></i></span>
</label>
</div>
</div>
</header>
This is how it looks like in Chrome (how it should):
This is Firefox:
IE is the same as Firefox, but the search bar is fine.
Okay I found a way to do it, but it may not be the best for some who have the same problem as I had:
First of all, to be able to see the background, I had to update to Firefox 65+ because .webp is supported from that version, it seems (for IE, it doesn't support it at all, which is a shame, so I just changed it to jpg)
For the searchbar however, I didn't find any good way to fix the padding, so I just used height in CSS to give it fixed height and that also fixed that problem, but may not be the best option for some.

On centered menu, left icon is missing left border

When I center my menu items using justify-content: center the left border of the left icon disappears. (View issue on JSFiddle)
My workaround is to manually assign a border using .add-left-border. However I'm not sure why this is required. Anybody know what's going on here?
#header-menu {
justify-content: center;
}
/* Why do I have to add this for border to show up? */
.add-left-border {
border-left: 1px solid rgba(34,36,38,.15);
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css"/>
<div class="ui icon menu" id="header-menu">
<a class="item add-left-border">
<i class="code branch icon "></i>
</a>
<a class="item">
<i class="github icon"></i>
</a>
<a class="item">
<i class="envelope icon"></i>
</a>
</div>
None of the buttons have a left border as they all apply borders to their right side (see below), while the first button depends on the menu's border to provide its visual boundary.
.ui.menu .item::before {
position: absolute;
content: '';
top: 0;
right: 0;
height: 100%;
width: 1px;
background: rgba(34,36,38,.1);
}
You will always need to use a bespoke solution as the framework doesn't appear to provide a centered menu. For purposes of consistency and cleaner HTML, you can achieve it with only CSS modifications:
#header-menu {
justify-content: center;
}
#header-menu .item:first-child::after {
position: absolute;
content: '';
top: 0;
left: 0;
height: 100%;
width: 1px;
background: rgba(34,36,38,.1);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css"/>
<div class="ui icon menu" id="header-menu">
<a class="item">
<i class="code branch icon"></i>
</a>
<a class="item">
<i class="github icon"></i>
</a>
<a class="item">
<i class="envelope icon"></i>
</a>
</div>

CSS: div with background image not displaying

At this site, there is a div.social below the Online Bookings at top right of the screen.
http://imgur.com/a/QhlIL
Note: I've not been able to upload images to SO for months - always says the image is too large (> 2MB) when it is 140 KB.
For some reason .social is not displaying, nor its sub-elements:
<div class="social">
<a title="Trip Advisor" href="#" target="_blank">
<div class="tripAdvisor"></div>
</a>
<a title="Facebook" href="#" target="_blank">
<div class="facebook"></div>
</a>
<a title="Instagram" target="_blank" href="#">
<div class="instagram"></div>
</a>
<a title="YouTube" target="_blank" href="#">
<div class="youtube"></div>
</a>
</div>
<style>
.headRight .tripAdvisor {
background: url(../images/social/tripadvisor.png) no-repeat;
width: 28px;
height: 22px;
}
</style>
.social is set to display: block; and there is enough room to fit the icons in.
Help appreciated.
Just checked the bug on your website.
You must apply the style to the child divs of .social
.social div {
display: inline-block;
margin-right: 15px;
display: inline; // remove this line
zoom: 1;
}
remove the
"display: inline"
Just keep
.social div {
display: inline-block;
margin-right: 15px;
zoom: 1;
}
from that class. Will work perfectly.

Absolute positioning does not work even if the parent is set to relative

<header>
<div class="row header-top">
<div class="row-inner">
<a href="/test1/" class="testxyz">
<i class="icon icon-test"></i>
<i icon-color="" class="icon icon-test" ng-style="{color: color}" style="color: rgb(51, 191, 238);"></i>
</a>
<div class="header-here">
<span>here</span>
<ul class="header-here-list">
</ul>
</div>
</div>
</div>
<span ng-controller="CNController" class="ng-scope">
<div class="row header-nav">
<div class="row-inner">
</div>
</div>
</span>
</header>
I'm trying to position div with class lb-ad-test the same as the div with class row header-top. I tried adding position: relative to the div with class row header-top and then added position: absolute to the div with class lb-ad-test and set top & right to 0, but the content in div does not show up when I do that. How can I place the content in the
below div same as the div with class row header-top?
<div ng-view="" class="app-container ng-scope">
<div id="lb-test" class="lb-ad-test ng-scope ng-isolate-scope" >
</div>
</div>
CSS:
.header-top {
background: #2b2b2b;
height: 93px;
position: relative;
}
.lb-ad-test {
position: absolute;
padding-bottom: 40px;
padding-top: 40px;
left: 0px;
right: 0px;
margin: 0 auto;
}
Change .leaderboard-ad-homepage in the CSS to .lb-ad-test? Your class names currently don't match.
You may try to set one class with left=0 and top = 0.

Set parent <div> width of children <div> using CSS

I have a three column markup for which the middle column #palette( elastic column) has following innerHTML markup snippet
<div id="palette">
<div id="wrapper" style="left: -354px; top: 0px;">
<div id="colours">
<ul>
<li class="swatch"><a tite="Beige" style="background-color:beige;" class="label" href="javascript:void(0);"><span> </span></a></li>
<li class="swatch"><a tite="Bisque" ... class="label" href="javascript:void(0);"><span> </span></a></li>
<li class="swatch"><a tite="Brown" style="background-color:brown;" class="label" href="javascript:void(0);"><span> </span></a></li>
<li class="swatch"><a tite="Coral" style="background-color:coral;" onclick="setColouringColour(this);" class="label" href="javascript:void(0);"><span> </span></a></li>
....
</ul>
</div>
<div id="brush-sizes"> <span style="width:16px; height:16px;" ><span>16</span></a></span> <span class="brush badge" style="width:32px; height:32px;"><a...><span>32</span></a></span> <span class="brush badge" style="width:64px; height:64px;"><a...><span>64</span></a></span> </div>
<div id="brushes"> <a class="selected btn btn-mini"...> </a> <a class="btn btn-mini"> </a> </div>
</div>
Where the following CSS rules apply
#palette {
float: left;
height: 100%;
position: relative;
width: 100%; overflow:hidden;
}
#wrapper {
display: inline-block;
position: absolute;
top: 0 !important;
white-space: nowrap;
width: auto;
}
Note: #palette is overflow:hidden so that #wrapper can be
scrolled using left:*n*px;. The children inside
#wrapper are all display:inline-block; clear:none;
The problem I am having is that #wrapper is not at "full width" of its children...thus I can't seem to be able to scroll to the very end.
What is the source of the problem here and how can I fix it using CSS ONLY( can it be accomplished CSS only?)
Apparently I needed to set one of the 2 remaining < div > to a fixed width and also tried setting the max- and min- width appropriately. Don't know why that worked

Resources