I have looked and looked, and can't find a solution to this that works (have tried LOTS!). I have a fixed header, and two columns that I want to expand with content, but want to appear full height if low on content. Then a footer that I want to appear either below the content (when lots) or at the bottom of the page. With the below HTML/CSS, the footer appears just off the viewscreen, but even worse, for some reason if I have enough text to push off the screen, my footer disappears!!
Edited: I figured it out. Yay!! on to next step.
HTML - EDITED
<header>
<div class="fixed-top">
<div style="height: 10px; background: #27AAE1;"></div>
<div id="Top_Bar" class="row">
<div class="col-sm-2">
<a><img src="images/nmdlogo.png" height=80px;></a>
</div>
<div class="col-sm-10">
<h1 "text-align=center";>Admin Panel</h1>
</div>
</div>
<div style="height: 10px; background: #27AAE1;"></div>
</div>
</header>
<main class="Site-content">
<div class="container-fluid h-100">
<div class="row h-100">
<div id="Menu_Panel" class="col-sm-2"><!-- Left Side Menu Area -->
Menu
</div><!-- End of col-sm-2 Left Side Menu Area -->
<div id="Main_Panel" class="col-sm-10"><!-- Main Area -->
Main Panel<br>
</div><!-- End col-sm-10 Main Area -->
</div><!-- End of Row -->
</div><!-- End of Container -->
</main>
<footer>
<div class="customHr"></div>
<div class="col-sm-10 offset-sm-2">
<span>Text Here</span><br>
<a style="color: white; text-decoration: none; cursor: pointer; font-weight: bold;" href="#">Link Name</a>
</div>
<div class="customHr"></div>
<div style="height: 10px; background: #27AAE1;"></div>
</footer>
CSS - EDITED
.Site {
display: flex;
min-height: 100vh;
flex-direction: column;
background-color: #2f4050;
}
.Site-content {
flex: 1;
margin-top: 120px;
}
#Menu_Panel{
background-color: #d10e1e;
}
#Main_Panel{
background-color: #ffffff;
}
#Top_Bar{
text-align: center;
color:#ffffff;
img-align: center;
background-color: #2f4050;
padding-top: 10px;
padding-bottom: 10px;
}
footer {
color:#ffffff;
text-align: center;
}
.customHr {
border-bottom: 1px solid #9fb1c2;
margin-top: 10px;
margin-bottom: 10px;
font-size: .8em;
padding-top: 5x;
padding-bottom: 5px;
}
I imagine you're looking for a footer that sticks to the bottom of your page than?
Edited:
Following css (based on your original) should give you what you're looking for
* {
margin: 0;
}
html {
height: 100%;
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
background-color: #2f4050;
position: relative;
margin: 0;
padding-bottom: 6rem;
min-height: 100%;
}
#Menu_Panel {
background-color: #d10e1e;
margin-top: 120px;
}
#Main_Panel {
background-color: #ffffff;
margin-top: 120px;
}
#Fixed_Top {
position: fixed; /* Set the navbar to fixed position */
top: 0;
}
#Top_Bar {
text-align: center;
color: #ffffff;
img-align: center;
background-color: #2f4050;
padding-top: 10px;
padding-bottom: 10px;
}
.footer {
color: #ffffff;
text-align: center;
width: 100%;
position: absolute;
right: 0;
bottom: 0;
left: 0;
}
.customHr {
border-bottom: 1px solid #9fb1c2;
margin-top: 10px;
margin-bottom: 10px;
font-size: .8em;
padding-top: 5x;
padding-bottom: 5px;
}
Related
I created a cards-based horizontal scroller. And the cards are nicely scrolling inside the wrapper. The issue I'm having is that even after I applied the z-index to our member-owner-card-image, the photos still go under the card when I want to put them on the top of each card.
Is there any solution so that I can add the image on top of the card? I'm trying to fix it, but no solution has been found.
.scrolling-wrapper {
-webkit-overflow-scrolling: touch;
height: 331px;
width: 100%;
padding-inline: 40px;
position: relative;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
z-index: 0;
}
.scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.card {
width: 100%;
flex: 0 0 auto;
background-color: green;
border-radius: 20px;
position: relative;
margin-right: 10px;
}
.our-member-owner-card-image {
position: absolute;
top: -30px;
z-index: 10;
}
.card-content {
position: absolute;
padding-top: 38px;
}
.member-detail {
padding-top: 55px;
line-height: 1.7;
}
.member-detail h3 {
text-align: center;
color: #263244;
font-weight: 700;
font-family: 'Lato';
}
.member-detail p {
text-align: center;
color: #737C89;
}
.member-description {
padding-inline: 20px;
color: #263244;
line-height: 1.6;
padding-top: 9px;
font-weight: 500;
font-size: 17px;
}
.member-description span {
color: red;
text-decoration: underline;
}
<div class="scrolling-wrapper">
<div class="card">
<div class="our-member-owner-card-image">
<img width="220px" src="https://images.unsplash.com/photo-1661961110144-12ac85918e40?ixlib=rb-4.0.3&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" />
</div>
<div class="card-content">
<div class="member-detail">
<h3>Sohaib</h3>
<p>Chairman</p>
</div>
<div class="member-description">
Sohaib Ashraf has extensive work experience during his career
of more than 25 years in the financial services sector.<span
>Read more</span
>
</div>
</div>
</div>
<div class="card">
<div class="our-member-owner-card-image">
<img width="220px" src="https://images.unsplash.com/photo-1661961110144-12ac85918e40?ixlib=rb-4.0.3&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" />
</div>
<div class="card-content">
<div class="member-detail">
<h3>Sohaib Ashraf</h3>
<p>Chairman</p>
</div>
<div class="member-description">
Sohaib Ashraf has extensive work experience during his career
of more than 25 years in the financial services sector.<span
>Read more</span
>
</div>
</div>
</div>
</div>
You could add the image as a background-image to the card. I added few examples how you can use background-image:
.card{
width: 400px;
height: 300px;
margin: 10px;
border-radius: 6px;
background-color: gray;
}
.card-1, .card-2 .image, .card-3 .image{
/* Here, we use background-image to set the image */
background-image: url("https://images.unsplash.com/photo-1661961110144-12ac85918e40?ixlib=rb-4.0.3&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80");
/* The background should be a cover photo,
so it fills the whole card: */
background-size: cover;
/* We don't want the image to repeat itself */
background-repeat: no-repeat;
/* When the ratio of the image changes, it will zoom into
this point, which we want to happen in the center of the image */
background-position: center;
}
.card-2, .card-3{
display: grid;
grid-template-rows: 1fr 1fr;
}
.card-2 .image{
border-radius: 6px 6px 0px 0px;
}
.card-3{
padding: 10px;
}
/* This is to demonstrate: */
h2{
color: white;
display: flex;
justify-content: center;
font-family: sans-serif;
}
<div class="card-1 card">
<h2>Test title</h2>
</div>
<div class="card-2 card">
<div class="image"></div>
<div class="content">
<h2> Test title</h2>
</div>
</div>
<div class="card-3 card">
<div class="image"></div>
<div class="content">
<h2> Test title</h2>
</div>
</div>
I'm working on a pomodoro clock that the h1 tag displaying the clock timer is not centered vertically (center of page). how could I center the text vertically without losing horizontal alignment? Also if someone can suggest how could I bring the - (minus) and + (plus) signs inside the controls closer to the middle without moving the text.
body {
background-color: #545454;
}
.title {
margin: auto;
text-align: center;
font-size: 30px;
}
.container {
text-align: center;
}
h2 {
font-size: 50px;
margin: 0 0 0 0;
}
.clockContainer {
position: relative;
text-align: center;
}
.timer {
margin: 0 50px;
margin-top: 70px;
text-align: center;
border: solid black 1px;
font-size: 44px;
width: 500px;
height: 200px;
display: inline-block;
}
.controlContainer {
position: absolute;
text-align: center;
width: 100px;
display: inline-block;
}
.control {
width: 100px;
height: 100px;
border-radius: 100px;
border: solid black 1px;
text-align: center;
margin-bottom: 20px;
}
.button {
margin-top: 30px;
}
.hide {
display: none;
}
.time {
margin-top: 5px;
margin-bottom: 5px;
font-size: 20px;
}
.ticker {
display: inline-block;
font-size: 30px;
margin-top: 0px;
}
.minus {
margin-right: 10px;
}
.plus {
margin-left: 10px;
}
<div class="container">
<!-- header title -->
<div class="title primary-text">
<h1>Pomodoro Clock</h1>
</div>
<!-- clock container -->
<div class="clockContainer">
<h2>Session</h2>
<!-- timer / clock -->
<div class="timer">
<h1 class="display">23:59</h1>
</div>
<!-- this section for controlling clock -->
<div class="controlContainer">
<div class="control">
<div class="button title">Start</div>
<div class="button hide title">Stop</div>
</div>
<div class="control">
<h3 class="time">30</h3>
<h3 class="title work">Work</h3>
<h3 class="minWork ticker minus">-</h3>
<h3 class="plusWork ticker plus">+</h3>
</div>
<div class="control">
<h3 class="time">10</h3>
<h3 class="title break">Break</h3>
<h3 class="minBrake ticker minus">-</h3>
<h3 class="plusBrake ticker plus">+</h3>
</div>
</div>
</div>
</div>
Your question is not totally clear but try applying this to the element:
position: relative;
top: 50%;
transform: translateY(-50%);
h1 {
vertical-align: middle;
}
This will align the h1 the way you want I believe.
Just remove height for .timer to center h1. Due to fixed height, h1 is not centered because it is bigger than 200px. If you want to decrease height of .timer just decrease h1's margin-top and margin-bottom.
To move + and - closer to middle decrease margin-top values for .ticker (e.g. from 0 to -5px). Demo:
body {
background-color: #545454;
}
.title {
margin: auto;
text-align: center;
font-size: 30px;
}
.container {
text-align: center;
}
h2 {
font-size: 50px;
margin: 0 0 0 0;
}
.clockContainer {
position: relative;
text-align: center;
}
.timer {
margin: 0 50px;
margin-top: 70px;
text-align: center;
border: solid black 1px;
font-size: 44px;
width: 500px;
display: inline-block;
}
.controlContainer {
position: absolute;
text-align: center;
width: 100px;
display: inline-block;
}
.control {
width: 100px;
height: 100px;
border-radius: 100px;
border: solid black 1px;
text-align: center;
margin-bottom: 20px;
}
.button {
margin-top: 30px;
}
.hide {
display: none;
}
.time {
margin-top: 5px;
margin-bottom: 5px;
font-size: 20px;
}
.ticker {
display: inline-block;
font-size: 30px;
margin-top: -5px;
}
.minus {
margin-right: 10px;
}
.plus {
margin-left: 10px;
}
<div class="container">
<!-- header title -->
<div class="title primary-text">
<h1>Pomodoro Clock</h1>
</div>
<!-- clock container -->
<div class="clockContainer">
<h2>Session</h2>
<!-- timer / clock -->
<div class="timer">
<h1 class="display">23:59</h1>
</div>
<!-- this section for controlling clock -->
<div class="controlContainer">
<div class="control">
<div class="button title">Start</div>
<div class="button hide title">Stop</div>
</div>
<div class="control">
<h3 class="time">30</h3>
<h3 class="title work">Work</h3>
<h3 class="minWork ticker minus">-</h3>
<h3 class="plusWork ticker plus">+</h3>
</div>
<div class="control">
<h3 class="time">10</h3>
<h3 class="title break">Break</h3>
<h3 class="minBrake ticker minus">-</h3>
<h3 class="plusBrake ticker plus">+</h3>
</div>
</div>
</div>
</div>
I have three divs with equal width and the third div to expand to full width below a breakpoint (991px to be exact) and all the divs stack upon each other when browser width is below 767px, and now i want equal margins(between divs & at the edges) so please let me know a way out. And I want to achieve this without any frameworks i,e just with the help of css.
Here's the code:
* {
box-sizing: border-box;
}
h1 {
margin: 25px;
text-align: center;
}
div[class|=col] {
position: relative;
margin-bottom: 10px;
border: 1px solid black;
}
html,
body {
margin: 15px;
}
.title {
border-left: 1px solid black;
border-bottom: 1px solid black;
width: 25%;
position: absolute;
top: 0px;
right: 0px;
color: black;
text-align: center;
}
#Title1 {
background-color: orange;
}
#Title2 {
background-color: white;
}
#Title3 {
background-color: green;
}
p {
background-color: gray;
width: 100%;
margin: 0px;
padding-left: 10px;
padding-right: 10px;
padding-top: 25px;
font-family: Helvetica;
color: black;
}
.row {
width: 100%;
}
<div class="row">
<div class="col-lg-4 col-md-6 ">
<section id="Title1" class="title">Chicken</section>
<p>Some text</p>
</div>
<div class="col-lg-4 col-md-6">
<section id="Title2" class="title">Beef</section>
<p>Some text</p>
</div>
<div class="col-lg-4 col-md-12">
<section id="Title3" class="title">Sushi</section>
<p>Some text</p>
</div>
</div>
Add classes to the 3 div's: div-1, div-2, div-3
#media only screen and (max-width:766px) {
.div-1.div-2.div-3 {
margin-bottom: 10px;
}
}
Like this you can add margin's for a particular resolution as per your requirement.
In the code below I have 3 col-md-4 that I want to reduce the space between to about 25px. I've tried reducing the margin between them along with increasing the padding on the left and right side of the first and last column respectively. The problem with this approach is that when the window size is manipulated it makes the image columns offset because of the increased padding.
HTML:
<div class="cards">
<div class="container">
<h2>
Our Expertise.
</h2>
</div>
<div class="row">
<div class="col-md-4">
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
</div>
<div class="col-md-4">
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
</div>
<div class="col-md-4">
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
</div>
</div>
</div>
CSS:
html, body {
margin: 0;
padding: 0;
font-family: 'Libre Baskerville', sans-serif;
}
.first {
padding-left: 200px !important;
}
.last {
padding-right: 200px !important;
}
.container {
max-width: 980px;
margin: 0 auto;
}
.header {
padding-top: 20px;
}
.header h1 {
font-size: 20px;
}
.nav li {
margin: 0px;
border: 0px;
}
.nav li a {
color: #333;
}
.jumbotron {
background-color: transparent;
padding-top: 100px;
padding-bottom: 100px;
}
.jumbotron h2 {
font-size: 50px;
}
.jumbotron h2 span {
color: #ffc200;
}
.banner {
background-color: #333;
height: 140px;
color: white;
text-align: center;
padding-top: 30px;
}
.cards {
background-color: #FFC200;
text-align: center;
}
.cards img {
margin-bottom: 25px;
padding: auto;
}
.cards h2 {
margin-top: 20px;
margin-bottom: 80px;
}
#media (max-width: 992px) {
.col-md-4 {
margin: 0 auto 0;
text-align: center;
width: 100%;
}
.cards img {
width: 60%;
}
}
#media (max-width: 500px) {
.header h1 {
text-align: center;
}
.nav li {
text-align: center;
width: 100%;
}
.cards img {
width: 100%;
}
}
There are suppose to be images in the columns but because I don't have 10 rep points it wont let me post them.
Just change the default column padding. You need to keep the total space between the columns an even number, so 24 would be good, you would simply change the default column padding from 15px to 12px and override the negative margin on the row as well:
.row {
margin-left: -12px!important;
margin-right: -12px!important;
}
div[class*='col-'] {
padding-left: 12px;
padding-right: 12px;
}
.inner {
border:1px solid black;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cards">
<div class="container">
<h2>
Our Expertise.
</h2>
</div>
<div class="row">
<div class="col-md-4">
<div class="inner">Column 1</div>
</div>
<div class="col-md-4">
<div class="inner">Column 2</div>
</div>
<div class="col-md-4">
<div class="inner">Column 3</div>
</div>
</div>
</div>
I'm using Twitter Bootstrap (RTL) with Sticky Footer and I have two columns in one row with 100% height. But when I open the page it has unnecessary scrollbar and I don't know why.
You can see it in JSFiddle.
This is my HTML code:
<div class="container-fluid mainContainer">
<div class="row-fluid full-height">
<div class="span3 sidebar itemContainer full-height">
<h2>ابزارهای در دسترس</h2>
#ToolsList.GetToolsList(this, Model)
</div>
<div class="span9 main itemContainer full-height">
<h2>بدنه</h2>
</div>
</div>
<div class="push"></div>
</div>
<footer class="footer itemContainer">
<div class="container">
<div class="row">
<div class="span12">
توسط احمدعلی شفیعی
</div>
</div>
</div>
</footer>
and This is my css StyleSheet (beside bootstrap's default code)
* {
font-family: Tahoma;
font-weight: 100;
margin: 0;
}
html, body {
height: 100%;
}
.sidebar {
border: 1px solid #C0C0C0;
padding: 5px;
margin-top: 10px;
}
.main {
border: 1px solid #C8C8C8;
padding: 5px;
margin-top: 10px;
padding-top: 70px;
padding-right: 25px;
}
.full-height {
height: 100%;
min-height: 100%;
}
.itemContainer {
background-color: #F5F5F5;
}
.mainContainer {
min-height: 100%;
height: 100%;
margin: 0 auto -40px;
}
.ToolItem {
margin-right: 20px;
}
.footer, .push {
clear: both;
height: 30px;
}
.footer {
margin: 5px;
margin-top: 60px;
padding-top: 5px;
}
from your description i think you want a sticky footer and a height 100% screen...
Check the documnetation and examples on Twitter Bootstrap:-
http://twitter.github.io/bootstrap/getting-started.html#examples
Their is an example for a sticky footer:-
http://twitter.github.io/bootstrap/examples/sticky-footer.html
For this you have to download the documentations of Twitter Bootstrap:-
http://twitter.github.io/bootstrap/index.html
Hope this works for you...
Thanks...