I'm going to make "universal" footer to my example of web-site. But I have any problems:
1. When page is short - footer doesn't work
2. When page is long - footer work
Footer's CSS:
.footer {
text-align: center;
position: relative;
bottom: 0px;
margin-bottom: -50px;
margin-left: -50px;
margin-right: -50px;
width: 110%;
height: 70px;
background-color: #FF9100;
font-size: 20px;
}
Footer's HTML:
<div class="footer">
<p>©All rights reserved</p>
</div>
Examlpes of images:
Try this:
.footer {
text-align: center;
position: fixed;
bottom: 0px;
width: 100%;
height: 70px;
background-color: #FF9100;
font-size: 20px;
}
You can assign position:fixed plus a bottom:0 rules to the .footer section, to force it to stay at the bottom of the page.
You can see a very basic code example below
*{
box-sizing:border-box;
margin:0;
padding:0;
}
main{
background:url('http://lorempixel.com/1200/1200/nature');
background-size:cover;
background-position:center center;
color:#fff;
text-align:center;
height:100vh;
}
footer{
position:fixed;
bottom:0;
}
<main>
<h1>Example page</h1>
<footer>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur molestias quos, soluta. Ut dolorum officia illum molestias quia commodi tempora cupiditate, earum deleniti amet sequi deserunt tempore, perferendis harum doloremque.</p>
</footer>
</main>
Related
a pop-up window is displayed when the user click to a specific link. . I can not figure out how to make it responsive. On smaller screens, the bottom of the pop-up window is out of range .
HTML code:
<div class="popup-wrapper">
<div class="popup">
<div class="popup-close">x</div>
<div class="popup-content">
<h2>Job Details</h2>
<div class="popup-job-description">
<div class="job-descriptions">
<p><span class="popup-job-description-title">Title: </span>Process Engineer</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-company">Company: </span>Undisclosed</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-location">Location: </span>Naypyitaw</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-location">Salary: </span>$75,000</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-description">Description: </span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa et similique ex, iusto sint in ratione aut magnam! Accusamus eveniet aspernatur nihil? Distinctio vel fugiat eius eaque? Quas earum adipisci quis voluptate animi id atque alias. Sapiente aut explicabo voluptate!</p>
</div>
<div class="job-descriptions requirements">
<p><span class="popup-job-description-requirements">Requirements: </span><ul>
<li>Bachelor's degree</li>
<li>At least 3 years of experience in a similar position</li>
<li>Fluent in English and Mandarin</li>
</ul></p>
</div>
<a class="apply-button" href="#">Apply Now</a>
</div>
</div>
CSS here:
/Job Popup/
.model{
width:100%;
height:100%;
background-color: black;
opacity: 0.5;
position: absolute;
top:0;
}
.popup-wrapper{
opacity: 1;
background: rgba(0,0,0,0.5);
position: fixed;
top:0;
left:0;
width:100%;
height:100%;
display: none;
}
.popup-wrapper .popup{
max-width: 60%;
min-width: 40%;
background: white;
margin: auto auto;
padding: 4rem 2rem 4rem 2rem;
}
.popup-wrapper .popup h2{
text-align: center;
color:#0b1f49;
letter-spacing: 2px;
margin-bottom: 1rem;
}
.popup-wrapper .popup-close{
position:absolute;
top:8%;
right:22%;
cursor:pointer;
font-size: 22px;
}
.popup-wrapper .popup a{
background:#5286ec;
color:white;
text-decoration:none;
padding:20px 35px;
position:relative;
}
.popup-job-description{
align-content:
}
.job-descriptions {
padding:0.75rem;
}
.job-descriptions span{
color:#2260dd;
font-weight: bold;
letter-spacing: 1.5px;
}
.popup-job-description .requirements ul{
margin: 0rem 0rem 2.5rem 1rem;
}
.popup-job-description .requirements li{
font-size: 18px;
margin: 5px;
}
I also have a little problem as you may have notice with the "x" or close-window at the top right of the pop-up window, I used a the absolute value as a display but it seems that it does really work.
Just add overflow-y: scroll; to your .popup-content.
Regarding the close button, you may want to use values in em. Here percentage is percentage of the width for the y coordinate and percentage of height for y coordinate. Since height vary with content, you get unpredictable results.
I want to display my website by three parts: header, page and footer. Now I can fixed my header and my footer, but the header shields a part of page and the page dont put down my footer(some content of my page displays behind my footer )
My template code:
<div class="fixed-header">
<...>
</div>
<div class="page">
<...>
</div>
<div class="fixed-footer">
<...>
</div>
My Css is :
.fixed-header {
position: fixed;
top: 0;
left: 0;
z-index: 2;
width: 100% !important;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
color: white;
text-align: center;
}
Anyone knows how to fix this problem?
Add padding on the top and bottom of the .page
.page {
padding-top: x // height of header
padding-bottom: x // height of footer
}
.fixed-header {
position: fixed;
top: 0;
left: 0;
z-index: 2;
background: red;
width: 100% !important;
height: 20px;
}
.fixed-footer {
background: blue;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
color: white;
text-align: center;
height: 20px;
}
.page {
margin: 20px 0;
background: pink;
width: 100px;
}
#media (max-width: 767px) {
.fixed-header, .fixed-footer {
height: 40px;
}
.page {
margin: 40px 0;
}
}
<div class="fixed-header">
<...>
</div>
<div class="page">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi odio, est rerum quod nisi ipsam laboriosam quam eius doloremque exercitationem. Laboriosam aut consequatur atque natus beatae explicabo sunt. Quam, labore.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi odio, est rerum quod nisi ipsam laboriosam quam eius doloremque exercitationem. Laboriosam aut consequatur atque natus beatae explicabo sunt. Quam, labore.
</div>
<div class="fixed-footer">
<...>
</div>
When I scale my site down or view on mobile/tablet, there is all of this margin/whitespace on right side and it cuts off text content in #main section. Why is this happening and how can I make it all scale correctly? I have tried overflow hidden on various parts which didn't solve anything and I have tried zeroing out margins and messing with padding. I'm unsure how to make it scale correctly and get rid of that extra margin/space on the right. There isnt much yet, only header, nav and #main section.
Thank you for your help in advance
html:
<body>
<header id="main-header">
<div class="container">
<h1 class="display-4">.Richardson</h1>
</div>
</header>
<nav id="navbar">
<div class="container">
<ul class="my-nav">
<li>Home</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</nav>
<section id="main">
<div class="container">
<div class="col-md-8" id="welcome-text">
<h1 class="display-4">Welcome</h1>
<hr class="rule">
<p><cite>"Discipline is the bridge between goals and accomplishments" ~ Jim Rohn</cite></p>
<p>Hey, I'm <span style="font-size: 24px; color: #FFFC31"><strong>Name!</strong></span> Congratulations on joining me in my path to becoming a highly valued, self-taught <span style="font-size: 24px; color:#FFFC31"><strong>Front-End Web Developer</strong></span>. My journey began with <span style="font-size: 24px; color: #FFFC31"><strong>Free Code Camp</strong></span> and the <span style="font-size: 24px; color: #FFFC31"><strong>Code Academy,</strong></span> as well as many youtube tutorials. I've learned <span style="font-size: 24px; color: #FFFC31"><strong>HTML, CSS and Javascript</strong></span> basics thus far. I aspire to put my coding skills to use by adding value and making a difference. Continually challenging myself and improving my craft. <span style="font-size: 24px; color: #FFFC31"><strong>I'm passionate</strong></span> about Nature, animals, traveling, serving the community, maintaining a healthy mind, body and spirit, and enjoying great food and craft beer with great people.</p>
</div>
</div>
</section>
<section>
<h1>Portfolio</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint recusandae, labore, cumque voluptas consequatur excepturi aut qui delectus error harum atque fuga voluptate voluptatibus rem, perferendis laboriosam, pariatur quae hic?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint recusandae, labore, cumque voluptas consequatur excepturi aut qui delectus error harum atque fuga voluptate voluptatibus rem, perferendis laboriosam, pariatur quae hic?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint recusandae, labore, cumque voluptas consequatur excepturi aut qui delectus error harum atque fuga voluptate voluptatibus rem, perferendis laboriosam, pariatur quae hic?</p>
</section>
css:
* {
margin: 0;
padding: 0;
}
.container {
width: 80%;
margin:auto;
overflow: hidden;
}
img {
min-width: 100%;
margin: 0;
}
h1,h2,h3,h4,h5,h6 {
font-family: "Helvetica", "geneva", sans-serif;
}
p {
font-family: sans-serif;
font-size: 1.3rem;
line-height: 2.5rem;
}
a {
color: #4e0250;
}
a:hover {
text-decoration: none;
background-color: gray;
padding: 10px;
color: #D3D3D3;
border-radius: 20px;
}
#main-header {
background: #4E0250;
color: silver;
text-align: center;
position: sticky;
top: 0;
right: 0;
z-index: 1;
}
#navbar {
text-align: center;
background-color: #D3D3D3;
color: #4e0250;
font-size: 1.4rem;
z-index: 1;
}
#navbar ul {
padding-left: 65px;
}
#navbar ul li {
text-align: center;
list-style: none;
padding-right: 40px;
display: inline;
}
#navbar {
position: fixed;
width: 100%;
}
#navbar .my-nav {
margin: 15px;
}
#main {
padding-top: 5rem;
background: url('../img/headon3.jpg') center center no-repeat;
background-size: cover;
min-height: 757px;
overflow: hidden;
}
#main .container {
margin-top: 55px;
margin-left: 150px;
}
#main #welcome-text {
background-color: rgba(92, 92, 92, 0.9);
color: #D3D3D3;
padding: 0 20px;
border-radius: 10%;
padding-bottom: 5px;
min-width: 40%;
}
#main h1 {
padding-top: 20px;
}
.rule {
border-top: 1px solid floralwhite;
padding-bottom: 10px;
}
Your main issue is you're not letting bootstrap take care of margins padding with rows and columns properly. In order to fix this immediate issue you have two problems:
First,
http://getbootstrap.com/docs/3.3/css/#grid-media-queries
#main .container {
margin-top: 55px;
margin-left: 150px;
}
Is getting in the way. Let the .container class take care of itself. It uses media queries to accurately define the margin-left at different widths. What you've done here is hard code it to always be 150px, and on an iphone that is most of the screen.
Second,
http://getbootstrap.com/docs/3.3/css/#grid
Container > rows > columns.
You are missing a row class here:
<div class="container">
<div class="row">
<div class="col-md-8" id="welcome-text">
I hope you can give me a hand.
What I'm Trying to do in a mobile version it's to leve the menu bar always visible using position fixed to the visitor and it work's fine, the issue is that the second div called aside it shows behind the menu bar and I really do not know how to show it after the menu bar.
I'm working in a 500px mobile version.
How can I fix this ?
I hope you can help me
....
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<style type="text/css">
body {
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
height: 1000px;
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.container {
width: 95%;
margin-right: auto;
margin-left: auto;
background-color: #f1f1f1;
height: 1000px;
max-width: 950px;
}
header{
height: 150px;
border-color: red;
border-style: dotted;
margin-bottom: 5px;
}
aside{
height: 200px;
border-color: blue;
border-style: dotted;
margin-bottom: 5px;
}
section{
height: 200px;
border-color: yellow;
border-style: dotted;
margin-bottom: 5px;
}
article{
height: 200px;
border-color: deeppink;
border-style: dotted;
margin-bottom: 5px;
}
footer{
height: 200px;
background-color: green;
border-style: dotted;
}
nav{
width: 100%;
float: left;
}
nav ul{
list-style: none;
padding: 0;
overflow: hidden;
margin-top: 56px;
}
nav ul li{
padding: 10px;
display: inline-block;
overflow: hidden;
}
nav ul li a{
color: red;
}
.menu {
display: none;
}
#media screen and (max-width:700px){
.container{
background-color: deeppink;
}
}
#media screen and (max-width:500px){
body{
margin: 0;
}
.container{
background-color: #CCCCCC;
width: 100%;
}
header{
margin-bottom: 5px;
border-style:none;
height: auto;
}
.menu{
display: block;
background-color: black;
width: 100%;
height: auto;
margin-top: 0px;
position: fixed;
}
.menu .icon-menu{
color: #fff;
padding: 10px;
font-size: 28px;
}
.menu .menu_txt{
color: #fff;
float: right;
padding: 10px;
font-size: 18px;
margin-top: 5px;
margin-right: 5px;
}
nav{
background-color: #595959;
height: 100%;
position: fixed;
width: 90%;
display: none;
}
nav ul{
border-color: deeppink;
margin-top: 0px;
}
nav ul li{
background-color: #3E3E3E;
display: block;
margin-top: 0px;
width: 100%
}
aside{
margin-top: 0px;
}
}
</style>
<link href="fonts.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<header>
<div class="menu">
<div class="menu_txt">MENU</div>
<div class="icon-menu"></div>
</div>
<nav>
<ul>
<li>page</li>
<li>page</li>
<li>page</li>
<li>page</li>
<li>page</li>
</ul>
</nav>
</header>
<aside>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id excepturi nesciunt in modi ratione alias vero ipsam optio quod quaerat fugiat est nihil temporibus, earum, necessitatibus ducimus hic cumque inventore?</aside>
<section>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic, incidunt necessitatibus asperiores quibusdam voluptas eos doloremque vitae consectetur earum facilis repudiandae ullam quisquam perferendis tempora. Illo, officia atque natus itaque.</section>
<article>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis necessitatibus explicabo obcaecati cum minima mollitia quam assumenda perferendis dicta. Cumque placeat, aliquam itaque ad quia accusamus autem tempora ex fugit.</article>
<footer>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus at natus pariatur eligendi possimus ipsa corporis rem rerum omnis, perferendis, earum vero dolorum optio, nihil odit dolores autem asperiores recusandae!</footer>
</div>
</body>
</html>
In your media query, add margin top or padding top to your body to push the content below the menu then add top: 0; to your menu to make sure it stays at the top.
http://codepen.io/anon/pen/JWwRmN
#media screen and (max-width:500px){
body{
margin: 0;
margin-top: 50px;
}
.menu{
display: block;
background-color: black;
width: 100%;
height: auto;
margin-top: 0px;
position: fixed;
top: 0;
}
I want put one image with a caption and after the image a description of the image. When I use absolute positioning for the image, the div goes under the image. How can i fix it so the div goes after the image: http://jsfiddle.net/qhcb0616/
.slide-square {
width: 148px;
height: 348px;
border:solid 1px black;
background: red;
}
.slide-square img {
position: absolute;
}
.slide-square h1 {
position: relative;
font-size:11px;
background :blue;
text-align:right;
float:right;
color:white;
padding:5px;
margin-top:5px;
margin-right:5px;
}
.slide-square div {
display: inline-block;
font-size: 50px;
}
<div class="slide-square">
<img src="http://www.flowers-online.com.au/flower-pictures/spring-surprise-flower-bouquet-b10l.jpg" alt="" width="148" height="148">
<h1>Scientific</h1>
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit debitis error magnam sunt numquam ab quasi omnis eaque dolore, perferendis quisquam, minus qui repudiandae possimus esse tempore ipsum adipisci soluta!</div>
</div>
What you need is make absolute the h1 element. Try this:
Make the parent relative:
.slide-square {
position: relative;
}
Then position the h1 on the parent
.slide-square h1 {
position: absolute;
top: 5px;
right: 5px;
}
Remove also the absolute for the img
Check the Snippet Below
.slide-square {
width: 148px;
height: 348px;
border: solid 1px black;
background: red;
position: relative;
}
.slide-square h1 {
position: absolute;
font-size: 11px;
background: blue;
text-align: right;
color: white;
margin:0;
padding: 5px;
top: 5px;
right: 5px;
}
.slide-square div {
display: inline-block;
font-size: 50px;
}
<div class="slide-square">
<img src="http://www.flowers-online.com.au/flower-pictures/spring-surprise-flower-bouquet-b10l.jpg" alt="" width="148" height="148">
<h1>Scientific</h1>
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit debitis error magnam sunt numquam ab quasi omnis eaque dolore, perferendis quisquam, minus qui repudiandae possimus esse tempore ipsum adipisci soluta!</div>
</div>