Footer won't stay down after i use float - html

I'm working on a responsive website. I have tried EVERYTHING and my footer won't stay down. It's because I used float:left. I don't want it to be fixed, i want it only to appear when i scroll to the bottom of the page. This is my code:
EDIT: ok so i took position:absolute out and now it works on the pages it didn't before. but on the pages where i didn't use float:left it doesn't work anymore.
footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 1.2em;
background-color: #24478f;
color: black;
text-align: center;
font-family: Calibri;
font-size: 4vw;
max-width: 100%;
clear: both;
}
#container figure {
width: 100%;
float: left;
display: block;
overflow: hidden;
}
...
#media only screen and (min-device-width: 1000px) {
#container figure {
width: 33%;
display: block;
overflow: hidden;
}
}
<section id="container">
<figure>
<a href="Portfolio.html#applications">
<img src="../imgs/74599-200.png">
</a>
<figcaption>Multimedia Applications</figcaption>
</figure>
<figure>
<a href="Portfolio.html#retrieval">
<img src="../imgs/info1600.png">
</a>
<figcaption>Information Retrieval</figcaption>
</figure>
<figure>
<a href="Portfolio.html#games">
<img src="../imgs/3281-200.png">
</a>
<figcaption>Computer Games</figcaption>
</figure>
</section>
<footer>
<p> Infia Abelha</p>
</footer>

in order to do that you can use min-height for your section like this
#container{min-height:500px}
and set footer position to relative
footer{position:relative}

remove position:absolute and it works
footer {
width: 100%;
height: 1.2em;
background-color: #24478f;
color: black;
text-align: center;
font-family: Calibri;
font-size: 4vw;
clear: both;
}
#container figure {
width: 100%;
float: left;
display: block;
overflow: hidden;
}
...
#media only screen and (min-device-width: 1000px) {
#container figure {
width: 33%;
display: block;
overflow: hidden;
}
}
<section id="container">
<figure>
<a href="Portfolio.html#applications">
<img src="../imgs/74599-200.png">
</a>
<figcaption>Multimedia Applications</figcaption>
</figure>
<figure>
<a href="Portfolio.html#retrieval">
<img src="../imgs/info1600.png">
</a>
<figcaption>Information Retrieval</figcaption>
</figure>
<figure>
<a href="Portfolio.html#games">
<img src="../imgs/3281-200.png">
</a>
<figcaption>Computer Games</figcaption>
</figure>
<div style="clear:both;"></div>
</section>
<footer>
<p> Infia Abelha</p>
</footer>

Related

Custom cursor disappears when hovering into the screen

I have a custom cursor on my page, but it disappears when hovering into the screen. It will appear for a millisecond when moving the cursor from outside the window onto the body, then disappear. How can I get the custom cursor to work?
body {
font-family: "Quicksand", sans-serif;
margin: 0;
padding: 0;
cursor: url("https://via.placeholder.com/50x50/000/fff"), auto;
}
main {
max-width: auto;
margin: auto;
cursor: url("https://via.placeholder.com/50x50/000/fff"), auto;
}
footer {
display: table;
text-align: center;
margin-left: auto;
margin-right: auto;
cursor: url("https://via.placeholder.com/50x50/000/fff"), auto;
}
img {
max-width: 100%;
height: auto;
display: table;
margin-left: auto;
margin-right: auto;
cursor: url("https://via.placeholder.com/50x50/000/fff"), auto;
}
<main>
<section class="test">
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
</section>
</main>
<footer>
<p>Lasse Unke - 2022.</p>
</footer>
It looks like the cursor isn't displaying when you hover over the text.
I hope this is your problem.
I set the cursor for * to the custom cursor and set it to !important
EDIT: For some reason the cursor isn't working in the snippet. Here is a jsfiddle link: https://jsfiddle.net/odajb362/
body {
font-family: "Quicksand", sans-serif;
margin: 0;
padding: 0;
}
main {
max-width: auto;
margin: auto;
}
footer {
display: table;
text-align: center;
margin-left: auto;
margin-right: auto;
}
img {
max-width: 100%;
height: auto;
display: table;
margin-left: auto;
margin-right: auto;
}
* {
cursor: url("https://via.placeholder.com/50x50/000/fff"), auto !important;
}
<main>
<section class="test">
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
<img src="https://via.placeholder.com/200x100" alt="test" />
</section>
</main>
<footer>
<p>Lasse Unke - 2022.</p>
</footer>
Hope this solves your problem 🙂
Have a nice day

Link from body shown in footer when testing but not in code

sorry for my naivety I'm very new to web development and have to create this for a uni project. The problem I'm having is that I have a grid of image thumbnails that link to full res versions on a separate page, the last image in the grid has a link that shows up and pushes content out the footer and inspect element on the page says the link it within the footer div but in the code it's not there. Any help would be appreciated.
.grid {
margin-left: 15%;
margin-right: 15%;
margin-top: 10px;
margin-bottom: 10px;
overflow: hidden;
}
.square {
display: inline-block;
float: left;
position: relative;
width: 30%;
padding-bottom: 30%;
/* = width for a 1:1 aspect ratio */
margin: 1.66%;
overflow: hidden;
}
.content {
position: absolute;
height: 100%;
width: 100%;
padding: 0%;
}
/* For responsive images */
.content .rs {
width: auto;
height: auto;
max-height: 100%;
max-width: 100%;
}
.footer {
height: 45px;
width: 100%;
background-color: white;
overflow: auto;
position: -webkit-sticky;
position: sticky;
z-index: 1;
bottom: 0;
list-style-type: none;
overflow: hidden;
padding-bottom: 5px;
padding-top: 5px;
overflow: hidden;
}
.footer a {
display: inline;
color: black;
text-align: center;
padding-top: 5px;
padding-bottom: 10px;
text-decoration: none;
font-family: 'myntieregular';
src: url('myntie-regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
font-size: 45px;
float: left;
text-decoration: none;
width: 33%;
text-align: center;
border-top-style: solid;
border-color: #c7c7c7;
border-width: 2px 0px;
}
<div class="grid">
<div class="square">
<div class="content">
<a href="Gallery\DSCF1629.html"><img class="rs" src="Images\Thumbnails\DSCF1629_Thumbnail.png" />
</div>
</div>
<div class="square">
<div class="content">
<a href="Gallery\DSCF1425.html"><img class="rs" src="Images\Thumbnails\DSCF1425_Thumbnail.png" />
</div>
</div>
<div class="square">
<div class="content">
<a href="Gallery\DSCF1723.html"><img class="rs" src="Images\Thumbnails\DSCF1723_Thumbnail.png" />
</div>
</div>
</div>
<div class="footer">
<img src="Image" alt="Instagram" style="width:30px;height:30px;">
<img src="Image" alt="Email" style="width:30px;height:30px;">
<img src="Image" alt="linkedin" style="width:30px;height:30px;">
</div>
Forgot to close the <a> tags within the "grid" divs.
It is hard to see since it is so off to the right.

How can I center and left align images?

I am working on an image gallery and want have the image's container be completely centered on the page, but the images are left aligned.
This is my desired output:
However, when I try to do a text-align: center on the container(id: gallery) I am getting the images displayed like this:
I tried following suit with a previous stack overflow question: CSS: Center block, but align contents to the left
and wrap the images in another div then align it with display: inline-block; and text-align: left; but the images just seem to align left on the entire page:
What can I do to accomplish my desired output?
HTML
<div id="gallery">
<div id="images">
<div class="container">
<a href="images/gallery/image1.jpg" data-lightbox="mygallery">
<img src="images/gallery/image1.jpg">
<div class="overlay">
<img src="images/magnify.png">
</div>
</a>
</div>
<div class="container">
<a href="images/gallery/image2.jpg" data-lightbox="mygallery">
<img src="images/gallery/image2.jpg">
<div class="overlay">
<img src="images/magnify.png">
</div>
</a>
</div>
</div>
</div>
CSS
#gallery{
text-align: center;
}
#images{
display: inline-block;
text-align: left;
}
img{
width: 300px;
cursor: pointer;
}
.overlay {
position: absolute;
right: 0;
left: 0;
cursor: pointer;
visibility: hidden;
color: transparent;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
transition: all ease-in .3s;
}
.overlay > img{
height: 50%;
width: 50%;
top: 50%;
visibility: hidden;
left: 50%;
transform: translate(-50%,-50%);
position: absolute;
}
.overlay:hover > img{
visibility: visible;
}
.container {
position: relative;
display: inline-block;
margin: 5px;
}
.container:hover .overlay {
visibility: visible;
opacity: .6;
background: black;
color: white;
}
How about styling the image wrapper .images like
.images {
width:80%;
margin:0 auto;
text-align:left;
}
this works
body{
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-content: center;
align-items: center;
}
section{
height:400px;
width:400px;
background:grey;
}
img {
margin:48px;
}
<section>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
</section>
Give your #gallery div a max-width, text-align: center, and margin:auto, then put your header in another div inside the #gallery, but outside the #images. Then put text-align: left on your #images div.
See example below:
#gallery {
text-align: center;
max-width: 420px;
margin: auto;
}
img {
width: 100px;
cursor: pointer;
}
.container {
display: inline-block;
}
#images {
text-align: left
}
<div id="gallery">
<div id="header">
<h1>Header</h1>
</div>
<div id="images">
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=d42">
<img src="http://thecatapi.com/api/images/get?id=d42">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=21o">
<img src="http://thecatapi.com/api/images/get?id=21o">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=49e">
<img src="http://thecatapi.com/api/images/get?id=49e">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=13v">
<img src="http://thecatapi.com/api/images/get?id=13v">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=6e6">
<img src="http://thecatapi.com/api/images/get?id=6e6">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=4bf">
<img src="http://thecatapi.com/api/images/get?id=4bf">
</a>
</div>
</div>
</div>
HTML
<h2>HEADER</h2>
<div class="container">
<img src=""/>
<img src=""/>
<img src=""/>
<img src=""/>
<img src=""/>
<img src=""/>
</div>
CSS
h2 {
text-align: center;
}
.container {
float: left;
}
img {
border: medium solid black;
width: 200px;
height: 350px;
margin: 5% 2%;
}

css horizontal center images without using % percent

There are some extra space on the right side in my gallery...
My images' container:
.my-gallery figure {
display: block;
float: left;
width: 150px;
}
Is it possible make images always horizontal center in different sized screen without using % percent value? Or someone has a genius idea that makes extra space not so weird?
Or % percent value trick is the only way?
In screen A:
In screen B:
.my-gallery {
width: 100%;
float: left;
}
.my-gallery img {
width: 100%;
height: 112px;
}
.my-gallery figure {
display: block;
float: left;
margin: 0 5px 5px 0;
width: 150px;
}
.my-gallery figcaption {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
min-height: 26px;
}
.my-gallery img {
max-width: 100%;
}
<div class="my-gallery">
<figure>
<a href="big1.jpg">
<img src="http://placehold.it/112x150" alt="1" />
</a>
<figcaption>111111111111111111111111</figcaption>
</figure>
<figure>
<a href="big2.jpg">
<img src="http://placehold.it/112x150" alt="2" />
</a>
<figcaption>222222222222222222222222</figcaption>
</figure>
<figure>
<a href="big3.jpg">
<img src="http://placehold.it/112x150" alt="3" />
</a>
<figcaption>3333333333333333333333333333333</figcaption>
</figure>
<figure>
<a href="big4.jpg">
<img src="http://placehold.it/112x150" alt="4" />
</a>
<figcaption>444444444444444444444444</figcaption>
</figure>
...
</div>
If using % is a problem, you could use css flexbox to get this done.
https://jsfiddle.net/76dybc3p/1/
Change css of .my-gallery and remove the float in figure
.my-gallery {
width: 100%;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.my-gallery figure {
display: block;
margin: 0 5px 5px 0;
width: 150px;
}
The most practical approach is to use #media query
I also changed the .my-gallery rule to
.my-gallery {
margin: 0 auto
}
Sample snippet
.my-gallery {
margin: 0 auto
}
.my-gallery img {
width: 100%;
height: 112px;
}
.my-gallery figure {
display: block;
float: left;
margin: 0 5px 5px 0;
width: 150px;
}
.my-gallery figcaption {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
min-height: 26px;
}
.my-gallery img {
max-width: 100%;
}
#media screen and (min-width: 310px) {
.my-gallery {
width: 310px;
}
}
#media screen and (min-width: 465px) {
.my-gallery {
width: 465px;
}
}
#media screen and (min-width: 620px) {
.my-gallery {
width: 620px;
}
}
<div class="my-gallery">
<figure>
<a href="big1.jpg">
<img src="http://placehold.it/112x150" alt="1" />
</a>
<figcaption>111111111111111111111111</figcaption>
</figure>
<figure>
<a href="big2.jpg">
<img src="http://placehold.it/112x150" alt="2" />
</a>
<figcaption>222222222222222222222222</figcaption>
</figure>
<figure>
<a href="big3.jpg">
<img src="http://placehold.it/112x150" alt="3" />
</a>
<figcaption>3333333333333333333333333333333</figcaption>
</figure>
<figure>
<a href="big4.jpg">
<img src="http://placehold.it/112x150" alt="4" />
</a>
<figcaption>444444444444444444444444</figcaption>
</figure>
</div>
I have no idea why you wouldn't use %, but this is another alternative: use a table to scaffold your items and set the property table-layout: fixed;
HTML
<table>
<tr>
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
</tr>
</table>
CSS
table{
table-layout: fixed;
}

My floated elements are being pulled too far to the left

I'm new to CSS, and I've looked for help in the previous forums on this issue. I think I'm doing everything right but my floated elements are being yanked to the left.
Here is my code:
div {
display: block;
}
.grid {
width: 660px;
position: relative;
float: left;
padding-bottom: 10px;
clear: left;
}
.home {
text-align: center;
float: left;
width: 33.3333333%;
position: relative;
padding: 25px;
}
.third {
display: inline-block;
position: relative;
float: left;
height: 150px;
width: 150px;
border-radius: 25px;
}
.third img {
float: left;
position: relative;
}
And my html:
<div class="grid">
<article class="home">
<article class="third">
<img src="" /></article>
</article>
<article class="home">
<article class="third">
<img src="" /></article>
</article>
<article class="home">
<article class="third">
<img src="" /></article>
</article>
</div>
Help please!
I can't comment yet…
Your original code on fiddle
The problem come from padding in .home class.
I have disabled padding:25px; here in .home class, because padding is added to width in CSS:
The modified version (without padding) on fiddle
Now it's not "pulled too far on the left".
What you can do instead, is to add margin:25px; to .third class, like this:
The modified version (with margin) on fiddle
EDIT: A CLEAN REVISITED VERSION:
The HTML code:
<div class="grid">
<article class="home">
<div class="third">
<img src="http://lorempicsum.com/nemo/350/200/1" />
</div>
</article>
<article class="home">
<div class="third">
<img src="http://lorempicsum.com/futurama/350/200/6" />
</div>
</article>
<article class="home">
<div class="third">
<img src="http://lorempicsum.com/up/350/200/6" />
</div>
</article>
</div>
The CSS code:
.grid {
width: 660px;
position: relative;
float: left;
padding-bottom: 10px;
clear: left;
}
.home {
text-align: center;
float: left;
width: 33.3333333%;
}
.third {
display:table-cell;
height: 150px;
width: 150px;
padding: 25px;
border-radius:25px;
vertical-align:middle;
background-color:#eee; //added just for test display
}
.third img {
border:none;
width: 100%;
height: auto;
}
The result here on fiddle.
Images are adaptative, centered vertically and horizontally.
The .third class have a light grey background color just for testing and displaying the curved borders and the centered images inside it.
I have also replaced in html code, the second <article> tag by a <div> tag, because it is redundant.
Please use the updated code I think it will work.
div {
display: block;
}
.grid {
width: 660px;
position: relative;
float: left;
padding-bottom: 10px;
clear: left;
}
.home {
text-align: center;
float: left;
width: 33.3333333%;
position: relative;
padding: 25px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.third {
display:block;
border-radius: 25px;
}
.third img {
width:100%;
height:auto;
}
Here's a possible correction of your code to you :
See this fiddle
I've changed a little the HTML structure like this :
<section class="home">
<article class="third">
<img src="http://lorempicsum.com/futurama/350/200/1" />
</article>
<article class="third">
<img src="http://lorempicsum.com/futurama/350/200/1" />
</article>
<article class="third">
<img src="http://lorempicsum.com/futurama/350/200/1" />
</article>
</section>
It's better for semantic to have section around article and not article around article.
I've simplify the CSS code like this :
section.home {
width: 660px;
position: relative;
float: left;
padding-bottom: 10px;
clear: left;
}
article.third {
text-align: center;
float: left;
width: 150px;
position: relative;
padding: 25px;
overflow: hidden;
}
.third img {
border-radius: 25px;
width: 100%;
position: relative;
}
If you use fluid width for container, then use fluid width for padding/margin of article.
In that case, i use fixed width of the container and for padding values.