I have a problem displaying images in the bottom of my web page.
This is what I want :
But it fails to load the images.
This is my code :
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/style.scss">
<title>Hello World</title>
</head>
<body>
<header class="header">
Mon App de Météo
</header>
<section class="view">
</section>
<nav class="nav">
<i class="home"></i>
<i class="about"></i>
</nav>
</body>
</html>
style.css
.header{
position: absolute;
top: 0;
left: 0;
right: 0;
height: 60px;
line-height: 60px;
color: #FFF;
text-transform: uppercase;
text-align: center;
background-color: #11a7ab;
}
.nav{
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 60px;
line-height: 60px;
text-align: center;
background-color: #4f597b;
}
.home{
background-image: url('../img/icon/home.png');
background-repeat: no-repeat;
}
.about{
background-image: url('../img/icon/about.png');
background-repeat: no-repeat;
}
a{
display: block;
width: 50%;
float: left;
}
And this is the hierarchy :
The console doesn't show any errors which makes me wonder what did I do wrong ?
Thanks!
If that is all your CSS, the problem is that the empty <i> elements have no size, so the background images have a 0x0 space to work with. Solution: give the i elements the size of the icons explicitly.
Related
a week ago I started to learn html and css and to practice I decided to emulate an old web page with what I learned so far. The page is the following: http://in3.org/info/reading.htm
I am having difficulty making the blue vertical line appear that is on the right side of the page.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ELECTRIC PAGES Reading Notes</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<main>
<header>
<img src="assets/ga.gif" alt="" />
<br>
<img src="assets/eptype2.gif" alt="" />
</header>
<aside class="aside1">
<img src="/assets/epnav5.gif" alt="" />
</aside>
<h2>Reading Notes</h3>
<aside class="aside2"></aside>
</main>
</body>
</html>
head,
body {
background-color: lightcyan;
margin: auto;
}
header {
width: 100%;
padding-left: 4.85%;
margin: auto;
}
.aside1 {
position: absolute;
width: 4.85%;
left: 0;
top: 0;
bottom: 0;
background-color: rgb(35, 168, 221);
}
.aside2 {
position: absolute;
width: 4.85%;
padding-right: 30%;
left: 0;
top: 0;
bottom: 0;
background-color: rgb(35, 168, 221);
}
img {
padding: 10px;
}
h2 {
color: red;
padding-left: 5.5%;
}
To make that blue vertical line I thought of using an empty aside tag with a width of 4.85% with a padding-right of 30%, but instead of having a distance of 30% to the right and occupying a 4.85% width, the aside is placed to the left of the page occupying 30% of the page.
I'd just give the wrapper/body-element your desired background-color, make a new container inside of that wrapper-element, give that your other desired background-color, and then center it. This way you don't have to make 2 new elements.
* {
margin: 0;
padding: 0;
}
body {
background-color: lightcyan;
}
.wrapper {
background-color: rgb(35, 168, 221);
height: 100vh;
max-width: 75%;
}
.container {
background-color: lightcyan;
max-width: 80%;
height: 100%;
margin-left: auto;
margin-right: auto;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ELECTRIC PAGES Reading Notes</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<main>
<div class="wrapper">
<div class="container">
<h2>Reading Notes</h3>
</div>
</div>
</main>
</body>
</html>
I'm currently following the tutorial on parallax effects on W3Schools. Basically, I have it so where the parallax is scrolling over my background correctly, but it's not scrolling over the text as well.
I tried a lot of things but it still doesn't work. I also saw one other post about this issue, but their code differed a lot from mine so it was hard to understand.
Here is the image of what is happening (the words are scrolling up with the page):
Here's my code:
*{
box-sizing: border-box;
}
body{
margin: 0px;
background-color: #ffffff;
}
ul{
text-align: center;
padding: 0px 20px;
margin: 12px auto;
list-style: none;
position: fixed;
z-index:10;
top: 0;
}
ul, li{
display: inline-table;
}
li{
margin: 10px 30px;
font-size: 15px;
color: #42385d;
font-weight: bold;
font-family: 'Roboto Slab', serif;
}
.navbar{
background-color: #ffcfda;
position: fixed;
width: 100%;
border-bottom: 1px solid #ffcfda;
z-index: 10;
height: 70px;
top: 0;
overflow: hidden;
}
#parallax{
background-image: url("pinkbackground.jpg");
min-height: 100vh;
background-attachment: fixed;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
position: relative;
}
.transition{
height: 200px;
background-color: #42385d;
width: 100%;
}
.intro-text{
text-align: center;
width: 100%;
color: #42385d;
padding: 37vh;
height: 100vh;
width: 100%;
font-size: 50px;
font-family: 'Roboto Slab', serif;
position: relative;
background-attachment: initial;
}
.question{
font-size: 30px;
font-family: 'Roboto Mono', monospace;
color: #42385d;
font-weight: bolder;
padding-top: 40px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>schpiel - Applying, Made Easier</title>
<!--meta data-->
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta name = "description" content =
"schpiel, like the name implies, makes applying easier.
no, it doesn't sound like that? :(. Using our new autofill
feature, with one click you can apply instantly!">
<!--styling-->
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght#1,300&family=Roboto+Slab&display=swap" rel="stylesheet">
<link rel="icon" href="https://i.imgur.com/RoPgdJh.jpg">
</head>
<body>
<div id="navigation">
<nav class="navbar";>
<ul>
<li>
<a>
Home
</a>
</li>
<li>
<a>
About
</a>
</li>
<li>
<a>
Contact
</a>
</li>
</ul>
</nav>
</div>
<div id="parallax">
<div class="intro-text">
text
<br>
here
</div>
</div>
<div class="transition"></div>
<section id="whatIsSchpiel">
<div class="question">
What is schpiel?
</div>
<div class="answer">
sscsdafads
</div>
</section>
</body>
<footer>
</footer>
Im working on a code and I would like to make the space between "Szafranowka" and "Apartaments & Restaurant" smaller. Here's how it looks like now: https://gyazo.com/d6843d8857e954acbae5c1da748c044b
I really cannot find the answer that would perfectly fit my expectations. Please, could any1 help me? :)
Also, I would like to make a small square around "Wejscie/Entrance", but when im trying to do it with the border, it looks like this: https://gyazo.com/f84fedc7a78854773b287e01ebd3a21f
Here's a part of code that im using to make a border:
<h5 style="border:3px; border-style:solid; border-color:#000000; padding: 1em;">Wejscie/Entrance</h5>
and here's my code:
HTML:
<!DOCTYPE HTML>
<head>
<title>Szafranowka - Apartments & Restaurant </title>
<meta name="viewport" content="width=device-width", initial-scale=1">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link rel="stylesheet" href="style.css" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet">
</head>
<body>
<!-- Główny DIV całej strony -->
<div id="container">
<!-- Lewa część tła strony, zamknięta w divie -->
<div id="background">
<img src="background.jpg"> </img>
</div>
<div id="header">
<h2>Szafranowka</h2> <p>Apartments & Restaurant </p>
<br></br> <h5 id="entrance">Wejscie/Entrance</h5>
</div>
</div>
</body>
</html>
CSS:
body {
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
}
#container
{
width: 100%;
height: 100%;
}
#background
{
width: 100%;
height: 100%;
position: absolute;
opacity: 0.5;
filter: blur(3px);
filter: contrast(50%);
filter: brightness(30%);
}
#background img
{
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
#header
{
position: absolute;
z-index: 1;
font-family: 'Tangerine', cursive;
text-align: center;
color: #9F5F9F;
font-size: 70px;
display: table-cell;
vertical-align: middle;
width: 100%;
text-shadow: 2px 2px #660055;
}
to your #entrance, try this :
#entrance {
width: 8rem; //or another size
margin auto; // to center
border: 2px solid;
}
<div id="header">
<h2>Szafranowka</h2> <p>Apartments & Restaurant </p>
<br></br> <span id="entrance">Wejscie/Entrance</span>
</div>
CSS:
h2{
margin:5px;
line-height:15px
}
#entrance{
border:1px solid;
}
<!DOCTYPE HTML>
<head>
<title>Szafranowka - Apartments & Restaurant </title>
<meta name="viewport" content="width=device-width", initial-scale=1">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link rel="stylesheet" href="style.css" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet">
<style>
body {
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
}
#container
{
width: 100%;
height: 100%;
}
#background
{
width: 100%;
height: 100%;
position: absolute;
opacity: 0.5;
filter: blur(3px);
filter: contrast(50%);
filter: brightness(30%);
}
#background img
{
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
#header
{
position: absolute;
z-index: 1;
font-family: 'Tangerine', cursive;
text-align: center;
color: #9F5F9F;
font-size: 70px;
display: table-cell;
vertical-align: middle;
width: 100%;
text-shadow: 2px 2px #660055;
}
#header h2
{
margin-bottom: -30px;
}
#entrance span
{
border: 1px solid;
padding: 15px;
}
</style>
</head>
<body>
<!-- Główny DIV całej strony -->
<div id="container">
<!-- Lewa część tła strony, zamknięta w divie -->
<div id="background">
<img src="background.jpg"> </img>
</div>
<div id="header">
<h2>Szafranowka</h2> <p>Apartments & Restaurant </p>
<br></br> <h5 id="entrance"><span>Wejscie/Entrance</span></h5>
</div>
</div>
</body>
</html>
So I am trying to change my background image, the problem is, as it is on my body, it is also changing on my other web page and I do not want it but I want to keep the same background image. Should I give an id/class to my body on my first page (where I want to hover function)?
<!DOCTYPE Html>
<head>
<meta charset="utf-8" />
<title>MakeHappy, One good thought everyday!</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="randomMessages.js"></script>
<link rel="stylesheet" href="MakeHappy.css" />
</head>
<div id="wink" class="imageSwap">
</div>
<body>
<header>
<nav>
<ul>
<a id="MakeHappy" href="Main.html">Make Happy</a>
<a id="Contact" href="#">Contact us</a>
<a id="Suscribe" href="#">Suscribe</a>
<a id="Project" href="#">Project</a>
</ul>
</nav>
</header>
</body>
\
<!DOCTYPE Html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="randomMessages.js"></script>
<title>MakeHappy, One good thought everyday!</title>
<link rel="stylesheet" href="MakeHappy.css" />
</head>
<body class="Main">
<input type="button" onclick="popup()" value="Click to be Happy!">
<div id="demo"></div>
</body>
\
body {
background-image: url("MakeHappy.jpg");
background-repeat: no-repeat;
background-position: 200px 60px;
background-size: 900px;
background-color: black;
}
body:hover{
background-image: url("MakeHappy2.jpg");
background-position: 200px 60px;
}
.Main{
background-size: 100px;
background-position:top;
}
.imageSwap{
position:absolute;
color: yellow;
padding: 150px;
bottom: 130px;
right: 500px
}
#MakeHappy{
color: white;
position: absolute;
right: 660px;
}
#Contact{
color: white;
position: absolute;
right: 660px;
bottom: 10px;
transform: rotate(180deg);
}
#Suscribe{
color: white;
position: absolute;
left: 320px;
bottom: 300px;
transform: rotate(270deg);
}
#Project{
color: white;
position: absolute;
right: 360px;
bottom: 300px;
transform: rotate(90deg);
}
.Main div{
color: white;
position: fixed;
}
input{
position: fixed;
bottom: 150px;
left: 625px;
}
You should give it a class with that specific background, if you only want the hover on lets say your startpage.
body {
background-image: url("MakeHappy.jpg");
background-repeat: no-repeat;
background-position: 200px 60px;
background-size: 900px;
background-color: black;
}
.startpage-background:hover{
background-image: url("MakeHappy2.jpg");
}
but your first html has errors, you shouldn't declare a div outside the body
Not valid html
<head>
<link rel="stylesheet" href="MakeHappy.css" />
</head>
<div id="wink" class="imageSwap">
</div>
<body>
</body>
But in general your html and css has not good practises and inconsistent code. I never use id to style a element, only classes. Also keep your classes and ids lowercase like some-class instead of SomeClass. Also I think you can avoid to absolute position your navigation elements.
I got a little problem with a website I'm currently working on. The background color/image I declare in an extern css file wont shown in my page.
Never had this issue before and I really can't figure out why this is not working..
My Code:
html {
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-size: 1em;
font-family: 'Calibri', sans-serif;
}
#navigation {
width: 100%;
height: 5%;
padding-top: 2%;
padding-left: 60%
background-image: url(./img/nav_bg.png);
}
#nav-ul {
list-style-type: none;
display: inline;
}
#navi-li {
float: left;
margin-left: 2%;
}
#server {
width: 100%;
height: auto;
background-color: #336699;
}
#evocity {
width: 100%;
}
<!DOCTYPE html>
<html lang="DE-de">
<head>
<title>DIAMOND DarkRP</title>
<meta charset="utf-8">
<meta name="language" content="de">
<meta name="keywords" content="Garry's Mod, GMOD, DarkRP, Roleplay, Dimaond">
<meta name="description" content="DIAMOND DarkRP - Forum, Teamspeak und weitere Informationen zum Diamond DarkRP Server">
<meta name="robots" content="index,follow">
<meta name="audience" content="alle">
<meta name="page-topic" content="Gameserver">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="navigation">
<ul id="nav-ul">
<li id="navi-li">Home</li>
<li id="navi-li">Server</li>
<li id="navi-li">TeamSpeak</li>
</ul>
</div>
<div id="server">
<img src="./img/evocity.jpg" id="evocity" alt="EvoCity v33x">
</div>
</body>
</html>