I have shared 2 images which mentioned below, In the first Screenshot there is a one div which label as This is test course, As you can see the footer div (which labeled as We're closed) is not sticky, I need the footer div as like second image. My conditions is something like - If the page don't have enough content then or you can say blank space then the footer div should stick at the bottom. Something like the second image.
I have tried position: fixed; it's showing perfectly but on the other pages it's still showing at the top which I don't want.
Another way I tried padding-top: 15vh; It's solving the problem but on the other page it's making blank space (Padding) which also not a good interface.
And tried many more methods like, bottom: 0; position: absolute; etc.
Current style applied in the div:
.footer {
padding: 0px 15px 10px 15px;
margin-bottom: 0px !important;
z-index: 11;
}
The HTML:
<div class="footer">
<div class="card card-style m-0">
<div class="card mx-0" data-card-height="120" style="height: 120px;">
<div class="card-center" style="z-index: 9">
Call
Email
</div>
<div class="card-center ms-3 ps-1">
<h1 class="font-20 show-business-opened working-message-above color-white mb-n1 disabled">We're Online!</h1>
<p class="show-business-opened working-message-under color-white opacity-90 mb-0 disabled">Call us Now! Let's have a
chat!</p>
<h1 class="font-20 show-business-closed working-message-above color-white mb-n1">We're Closed!</h1>
<p class="show-business-closed working-message-under color-white opacity-90 mb-0">We'll be back very soon!
</p>
</div>
<div class="card-overlay rounded-0 show-business-opened bg-highlight-dark disabled"></div>
<div class="card-overlay rounded-0 show-business-closed bg-red-dark"></div>
</div>
<div class="content p-3 pt-0 mt-0">
<p>If you have any queries or facing techinal problem, You can simply inform us, Our team will resolved your
issue as soon as they can.</p>
</div>
</div>
How can I resolve this?
You can do that starting from your HTML structure. for example, if your website has a header, main container, and footer, then you can manage their height to the viewport. specifically the main container's min-height to the viewport.
* {
margin: 0;
padding: 0;
overflow-x: hidden;
}
.header {
width: 100vw;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
background: lightcoral;
}
.main-container {
width: 100vw;
/* min height should fill the viewport then to make all element in view port,
reduce other elements height from this min height including every pixel like borders or margin etc. */
min-height: calc(100vh - 300px);
/* or you can try this way if it's suitable for you */
/* min-height: 100vh; */
display: flex;
justify-content: center;
align-items: center;
background: lightblue;
}
.footer {
width: 100vw;
height: 250px;
display: flex;
justify-content: center;
align-items: center;
background: lightseagreen;
overflow: auto;
/* padding: 0px 15px 10px 15px; */
/* margin-bottom: 0px !important; */
z-index: 11;
/* border: 1px solid red; */
}
<header class="header">header</header>
<div class="main-container">main container</div>
<div class="footer">
<div class="card card-style m-0">
<div class="card mx-0" data-card-height="120" style="height: 120px;">
<div class="card-center" style="z-index: 9">
Call
Email
</div>
<div class="card-center ms-3 ps-1">
<h1 class="font-20 show-business-opened working-message-above color-white mb-n1 disabled">We're Online!</h1>
<p class="show-business-opened working-message-under color-white opacity-90 mb-0 disabled">Call us Now! Let's have a
chat!</p>
<h1 class="font-20 show-business-closed working-message-above color-white mb-n1">We're Closed!</h1>
<p class="show-business-closed working-message-under color-white opacity-90 mb-0">We'll be back very soon!
</p>
</div>
<div class="card-overlay rounded-0 show-business-opened bg-highlight-dark disabled"></div>
<div class="card-overlay rounded-0 show-business-closed bg-red-dark"></div>
</div>
<div class="content p-3 pt-0 mt-0">
<p>If you have any queries or facing techinal problem, You can simply inform us, Our team will resolved your
issue as soon as they can.</p>
</div>
</div>
Related
SO I want to reach this image
But i am getting this result, and i have a sense that i misused boostrap for the grid, but i am not sure it has to do with my initial problem
I want to reach a parallax element too by translating the image on the x axis on click as in this gif So i am worried if using margin would make it worse
EDIT: my problem isn't with the grid and text placement, i want to position the trees ( right and left on the right sides) which isn't working at all. I know it is immature to say this but idc of the grid if its work like in the prototype
here is my code
<section id="abtus">
</span>
<div class="col-4" style="margin-bottom: 700px;"><img class="tree" src="./images/tree1.png" width="750"></div>
<div class="grid text-center " >
<div class="cols-4 pb-3"><p class="text1">WHO WE ARE</p></div>
<div class="cols-4 p-1 "><p class="text2">We are two sisters who come from a similar <br>
background of love for everything creative and magical.</p> </div>
<div class="cols-4 p-1 "> <p class="text2">We aim to deliver your stories with interesting <br>
visually pleasing magic that separates you from the rest!</p></div>
<div class=" cols-4 p-1 pb-5 "> <p class="text2">To guarantee great quality work and also an added fun <br>
element to your project.</p></div>
<div class="cols-1"><img src="./images/Group 33.svg"></div>
</div>
<div class="grid px-5">
<div class="cols-4 offset-md-2"><img src="./images/Group 30.svg" width="90"> </div>
<div class=" cols-4 pb-4"></div>
<div class=" cols-4 pb-2"></div>
<div class=" cols-4"><img src="./images/Group 46.svg" width="150"></div>
</div>
<div class="grid text-center">
<div class="cols-4 pb-3"><p class="text1">THE TEAM</p></div>
<div class="cols-4 pb-5"><p class="text2 pb-4">We have a rich experience in the market, especially <br>
in gaming and animation. We work with several tasks <br>
such as visual development, concept art, character design, <br>
graphic design, branding, and social media.<br><br>
Yes, We do everything!</p> </div>
<div class=" cols-4 pb-4"></div>
<div class=" cols-4 text-center"><img src="./images/Group 50.svg" width="120"></div>
</div>
</span>
</section>
the relative css
section{
flex: none;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
scroll-snap-align: start;
}
.tree{
top: 0;
left:0;
position:absolute ;
z-index: 1;
}
.text1{
text-align: left;
left: 0;
color: #20122B;
font-family: 'Lato';
font-weight: 900;
font-size: 30px;
}
.text2{
text-align: left;
color: #20122B;
font-family: 'Lato';
font-weight: 500;
font-size: 0.9em;
line-height: 16px;
}
.arrow1{
display: grid;
place-items: center;
place-content: center;
border-left: 3px solid #ffffff;
border-bottom: 3px solid #ffffff;
width: 10px;
height: 10px;
border-radius: 0.2em;
transform: rotate(225deg);
}
.right{
margin-right: 150px;
float:left;
}
.left{
margin-right: 100px;
float:left;
transform: rotate(45deg);
}
I have been trying very hard to make a split screen using Bootstrap. Here's what it looks like when I managed to do it with CSS:
But I need to make it responsive to mobile users so I'm remaking it with Bootstrap. However the image and textbox don't resize for some reason.
By responsive I mean that it should become single row with 2 columns and vice versa depending wether you're on a desktop or mobile.
Edit: Sorry for this sudden change, but I'm now using Bootstap ver5.
#promotion-textbox {
top: 115px;
display: inline-block;
margin-right: 5vw;
left: 55%;
background-color: white;
object-fit: fill;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
#promotion-title {
padding: 10px;
position: static;
color: #23272a;
font-size: 3vw;
overflow: hidden;
display: inline-block;
}
#promotion-button {
width: 40vw;
opacity: 0.8;
left: 75%;
transform: translate(-50%, -75%);
margin-left: auto;
margin-right: auto;
top: 620px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<div class="row">
<!-- First Half -->
<div class="col-md-6">
<img class="img" src="https://via.placeholder.com/100">
</div>
<!-- Second Half -->
<div class="col-md-6">
<div id="promotion-textbox">
<div id="promotion-title">
Duck Zone is the best game of all time, I mean just look at these awesome reviews:<br /><br /> TheP0mp21 Says:<br />- Game is pretty good but it needs a your mum duck that is extremely fat and spawns other ducks.
</div>
</div>
</div>
</div>
A few things, if you are using a library then take advantage of it, use its utility classes, and learn its grid system:
Add vh-100 utility class to your row
Add w-100 h-100 in img tag HTML and in CSS add object-fit: cover
Because you've updated your question from bootstrap-4 to ootstrap-5, to remove the spacing in order to hide the horizontal scrollbar you need to replace no-gutters to g-0
Note: You have a lot of styles that doesn't make sense, such left/top without position
I also I've improved your code
#promotion-textbox {
background-color: white;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
margin-bottom: 20px;
}
#promotion-title {
padding: 10px;
color: #23272a;
font-size: 3vw;
}
#promotion-button {
opacity: 0.8;
border: 2px solid #fff;
color: #fff;
padding: 10px 20px;
background: transparent;
}
img {
object-fit: cover
}
.col-6:last-child {
background: darkgray
}
.promotion-column {
display: flex;
flex-direction: column;
padding: 20px;
align-items: center;
justify-content: center;
height: 100%;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="row g-0 vh-100">
<!-- First Half -->
<div class="col-md-6">
<img class="img w-100 h-100" src="https://picsum.photos/300/200">
</div>
<!-- Second Half -->
<div class="col-md-6">
<div class="promotion-column">
<div id="promotion-textbox">
<div id="promotion-title">
Duck Zone is the best game of all time, I mean just look at these awesome reviews:<br /><br /> TheP0mp21 Says:<br />- Game is pretty good but it needs a your mum duck that is extremely fat and spawns other ducks.
</div>
</div>
<button type="button" id="promotion-button">All Projects</button>
</div>
</div>
</div>
You must use responsive image if you want it to be responsive. I also removed gutters from the row.
EDIT: made some improvment, height:100vh is really helpful. Takes exactly the height of the window.
.half {
border: 1px solid red;
height: 100vh;
position: relative;
}
.my-image {
width: 100%;
height: 100%;
}
#promotion-textbox {
top: 115px;
display: inline-block;
background-color: white;
object-fit: fill;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
#promotion-title {
padding: 10px;
position: static;
color: #23272a;
font-size: 3vw;
overflow: hidden;
display: inline-block;
}
#promotion-button {
width: 40vw;
opacity: 0.8;
left: 75%;
transform: translate(-50%, -75%);
margin-left: auto;
margin-right: auto;
top: 620px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="row no-gutters">
<!-- First Half -->
<div class="half col-sm-6">
<img class="img my-image" src="https://picsum.photos/536/354">
</div>
<!-- Second Half -->
<div class="half col-sm-6">
<div id="promotion-textbox">
<div id="promotion-title">
Duck Zone is the best game of all time, I mean just look at these awesome reviews:<br /><br /> TheP0mp21 Says:<br />- Game is pretty good but it needs a your mum duck that is extremely fat and spawns other ducks.
</div>
</div>
</div>
</div>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
To make a split screen (two columns) use .row as parent and .col-md-6 for children. "md" part means that columns will expand to full screen width on medium and smaller screens( you can choose: xxl, xl, lg, md, sm, xs). TO make it fit the screen vertically add min-height: 100vh; for both columns and media query for the break point with min-height: 50vh;
source: https://getbootstrap.com/docs/4.6/layout/grid/
Bootstrap 4 example (works in bootstrap 5 and 4):
CSS:
.img-col{
background: url(https://via.placeholder.com/100) center center no-repeat;
background-size: cover;
}
.min-h-50{
min-height:100vh;
}
#media only screen and (max-width: 767px) {
.min-h-50{
min-height:50vh;
}
}
HTML:
<div class="row">
<div class="col-md-6 img-col min-h-50">
</div>
<div class="col-md-6 bg-dark min-h-50">
<div class="row justify-content-center h-100">
<div class="col-10 align-self-center">
<div class="bg-white p-3">rff</div>
<div class="mt-3 text-center"><button class="btn btn-primary">xxx</button></div>
</div>
</div>
</div>
</div>
I have the following layout on my webpage:
The left side, represented here by D, is perfect. There's a lot of content in there and it scrolls as it should. Even when the content grows, the height remains 100% of the webpage's height while the scroll increases.
The right side has some content on B. Everything fine as well. Using Bootstrap 4, B and A are row inside a col and, as such, have 50% share of the parent container.
The problem is that I would A to fill all of the remaining space while being scrollable independent of the number of Cs inside it. This means that with 1 C, it should have its height as half of the page's height (as depicted in the picture) and by having 20 Cs, it should occupy the same height (while being scrollable such that the user can see the 20th C by scrolling to the bottom of A).
So, I am being able to achieve vertical scrollability on A if I set a hardcoded height as height=350px but this is far from ideal since desktops have varying heights. On the other hand, if I don't set a height, A's height become the height necessary to wrap all elements inside it, so with 4 Cs the right-bg layout already surpass the left part of the webpage, causing a break on the overall layout.
<div class="right-bg">
<div class="container col" style="height:100%">
<div class="row"> <!-- THIS IS B -->
<div class="col">
<div class="row" id="chart-div">
<canvas id="myChart"></canvas>
</div>
<div class="row horizontal-menu-wrapper">
</div>
</div>
</div>
<div class="container row ranking-container"> <!-- THIS IS A -->
<div class="container rounded-card"> <!-- THIS IS C -->
<div class="row">
<div class="col-lg-1 col-md-1 col-sm-1">
<div id="ranking-trophy-header" class="row card-header">
<i title="General" class="fas fa-trophy header-icon"></i>
</div>
</div>
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="row row-card">
<div class="col-lg-5 col-md-5 col-sm-5">
<p class="ranking-percentage-value"> Top 1%</p>
</div>
<div class="col ranking-field">
<p class="form-field">Position</p>
<p class="form-ranking-value"><span class="absolute-ranking">#<span class="absolute-ranking-value">83</span></span></p>
</div>
<div class="col ranking-field">
<p class="form-field">Pool</p>
<p class="form-pool-value">9470</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS:
html {
height: 100%;
}
body {
height: 100%;
}
.left-bg {
flex-flow: column;
display: flex;
width: 54%;
height: 100%;
overflow: scroll;
padding-bottom: 10px;
}
.right-bg {
flex-flow: column;
display: flex;
width: 46%;
height: 100%;
padding-top: 12px;
}
.ranking-container {
vertical-align: center;
margin: 5px;
margin-top: 15px;
margin-bottom: 5px;
padding: 15px;
overflow: scroll;
border-radius: 10px;
margin-bottom: -9999px;
padding-bottom: 9999px;
}
Use d-flex, flex-column, and h-100 for its parent. And flex-grow-1 for the row that you want that it occupies all of the available space.
html,
body {
height: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="container d-flex flex-column h-100 bg-light">
<div class="row">
<div class="col p-5 bg-danger"></div>
</div>
<div class="row bg-info flex-grow-1">
<div class="col"></div>
</div>
</div>
It works as expected irrespective of how many row you have.
https://codepen.io/anon/pen/RJVaKw
You need to use bootstrap-4.1 because flex-grow-1 does not exist in the earlier version of it.
Most of your style is unnecessary. You can achieve this with pure Bootstrap classes.
Update
It does not work in Chrome. To fix the issue, use flex-grow-1 for the column inside flex-grow-1 row. And set its overflow-y to scroll. You may hide the scrollbars too.
html,
body {
height: 100%;
}
.overflow-y-scroll {
overflow-y: scroll;
}
/*hide scrollbar in webkit-browsers */
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #FF0000;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="container d-flex flex-column h-100 bg-light">
<div class="row">
<div class="col p-5 bg-danger"></div>
</div>
<div class="row bg-info flex-grow-1">
<div class="col flex-grow-1 bg-primary overflow-y-scroll">
<!-- content -->
</div>
</div>
</div>
https://codepen.io/anon/pen/jKmYdq
Try it:
<div class="container col" style="position: absolute; top: 0px; bottom: 0px; ">
</div>
You can give any block level element an explicit height and then add:
overflow: auto;
which will add a scrollbar to that element if the content of the element is taller than the element's own explicitly declared height.
Here is a layout similar to the one you have described above, using CSS Grid.
Note that vertical scrollbars automatically display in the areas D and A because the content within those elements is taller than the height of the parent elements themselves.
Working Example:
main {
display: grid;
grid-template-rows: 50% 50%;
grid-template-columns: 50% 50%;
width: 80vw;
height: 80vh;
border: 6px solid rgb(191, 191, 191);
border-radius: 15px;
}
.a-area {
background-color: rgb(255, 63, 63);
}
.b-area {
background-color: rgb(255, 127, 0);
}
.c-area {
border: none;
background-color: rgb(63, 63, 63);
}
.d-area {
grid-area: 1 / 1 / 3 / 2;
color: rgb(127, 127, 127);
}
main div {
color: rgb(255, 255, 255);
border: 4px solid rgb(191, 191, 191);
overflow-x: hidden;
overflow-y: auto;
}
main div h2 {
margin: 0;
padding-right: 6px;
font-size: 24px;
line-height: 36px;
text-align: right;
}
main div p,
.c-area {
margin: 6px 12px;
}
<main>
<div class="d-area">
<h2>D</h2>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
</div>
<div class="b-area">
<h2>B</h2>
</div>
<div class="a-area">
<h2>A</h2>
<div class="c-area">
<h2>C</h2>
</div>
<div class="c-area">
<h2>C</h2>
</div>
<div class="c-area">
<h2>C</h2>
</div>
<div class="c-area">
<h2>C</h2>
</div>
<div class="c-area">
<h2>C</h2>
</div>
<div class="c-area">
<h2>C</h2>
</div>
</div>
</main>
I am coding my first website. I am attempting to create a vertical timeline using Bootstrap 4, where the bar of the timeline is in between two columns. Currently, I cannot place text in the first column and an image directly to the right in the second column. The image is always pushed down to the next row. When I examine the element, I notice a large margin (orange area). How do I remove this?
This is my first post on Stack Overflow. I apologize if this is a bit long.
Thanks!
Relevant Code
<div class="row mt-3 no-gutters">
<div class="col-md-12">
<div class="timeline">
<div class="timeline-item-left">
<div class="col-md-6 text-right p-3 mr-0">
<h3>December 2017</h3>
<h5>Big Basin Redwoods State Park </h5>
Berry Creek Falls Loop | 10 Miles
</div>
<div class="offset-md-6 col-md-6 text-left">
<a href="adventure_images/big_basin.jpg">
<img src="adventure_images/big_basin.jpg" class="img-thumbnail" alt="Big Basin" width="150">
</a>
</div>
</div>
CSS
.timeline {
position: relative;
max-width: 800px;
margin: 0 auto;
}
/* Containers around content */
.timeline-item-left {
padding: 10px 30px;
position: relative;
/* background-image: <img src="adventure_images/spiration_light.png">;
background-repeat: repeat-x; */
background-color: white;
width: 100%;
}
.timeline-item-right {
padding: 10px 30px;
position: relative;
/* background-image: <img src"adventure_images/spiration_light.png">;
background-repeat: repeat-x;*/
background-color: white;
width: 100%;
}
Inspection of Element Screenshot
Website Link (for more detailed inspection)
You can use below css in your style.
.timeline-item-left,.timeline-item-left {display: flex}
and remove class offset-md-6.
Try below
.timeline-item-left {
padding: 10px 30px;
position: relative;
background-color: white;
width: 100%;
display: flex;
}
remove offset-md-6
<div class="offset-md-6 col-md-6 text-left">
I'm slowly getting into CSS and HTML and so far I've been making a page where there's a navbar on top and a list of elements below it. The elements in said list change their shape, too, but this is not the purpose of my question.
The issue I'm having is that while scrolling, the container class elements just scroll on top of the navbar, making it kinda pointless.
header {
position: fixed;
display: flex;
left: 0;
right: 0;
top: 0;
margin: 0;
background: red;
}
main {
margin: 0 auto;
padding-top: 80px;
background: yellow;
}
.container {
margin: 10px;
display: flex;
border: 1px solid #aaa;
height: 200px;
min-width: 700px;
flex-grow: 1;
position: relative;
}
.container div.containerinfo {
display: flex;
flex-wrap: wrap;
flex: 0.75;
flex-direction: column;
background-color: white;
}
<header>
<h1 id="title">Navbar</h1>
</header>
<main>
<section>
<div class="container">
<img src="broken" alt="broken link">
<div class="containerinfo">
</div>
</div>
<div class="container">
<img src="broken" alt="broken link">
<div class="containerinfo">
</div>
</div>
<div class="container">
<img src="broken" alt="broken link">
<div class="containerinfo">
</div>
</div>
<div class="container">
<img src="broken" alt="broken link">
<div class="containerinfo">
</div>
</div>
<div class="container">
<img src="broken" alt="broken link">
<div class="containerinfo">
</div>
</div>
</section>
</main>
Here's a jsfiddle: https://jsfiddle.net/ckuuxqqr/6/
Any help would be appreciated.
Because your header comes first in the source code, the yellow div elements will layer above it on the z-axis.
Here are two options to make header appear on top:
Add z-index: 1 to header. This will move the header to the top of other elements without a higher z-index value. (The default value for all elements is auto.) revised fiddle
Put the header element last in the source code. revised fiddle
You will need to add z-index:1; to your header css. z index will determine the "stacking" of elements on the page. The higher the index the higher it will stack on the page.
Add the z-index and here's why-->https://developer.mozilla.org/en-US/docs/Web/CSS/z-index