Text below css slider - html

I want to make a 100% css slider. The slider in the jsfiddle below works, but I want to add text below the image that moves with the image. And there I am stuck. I don't understand why the text doesn't show up at all.
Please help...
jsFiddle
html
<div class="slider-wrap">
<div id="slider">
<div class="jt_slides">
<div class="jerslides">
<img src="https://blog.psprint.com/sites/default/files/2014/06/Palette-Fathers-Day-COLOURlovers-Google-Chrome_2014-06-10_14-53-52.png" alt="">
More...
<h2 class="title">Title text 1</h2>
<div class="excerpt">
<div class="stars"><span>★</span><span>★</span><span>★</span><span>★</span><span>★</span></div>
<p class="whatever" href="#">Some text 1</p>
</div>
</div>
<div class="jerslides">
<img src="https://blog.psprint.com/sites/default/files/2014/05/Palette-Lookin-Like-Summer-COLOURlovers-Google-Chrome_2014-05-29_10-07-53.png" alt="">
More...
<h2 class="title">Title text 2</h2>
<div class="excerpt">
<div class="stars"><span>★</span><span>★</span><span>★</span><span>★</span><span>★</span></div>
<p class="whatever" href="#">Some text 2</p>
</div>
</div>
<div class="jerslides">
<img src="https://blog.psprint.com/sites/default/files/2014/04/Palette-Mothers-Day-COLOURlovers-Google-Chrome_2014-04-28_09-24-37.png" alt="">
More...
<h2 class="title">Title text 3</h2>
<div class="excerpt">
<div class="stars"><span>★</span><span>★</span><span>★</span><span>★</span><span>★</span></div>
<p class="whatever" href="#">Some text 3</p>
</div>
</div>
<div class="jerslides">
<img src="https://blog.psprint.com/sites/default/files/2014/06/Palette-Fathers-Day-COLOURlovers-Google-Chrome_2014-06-10_14-53-52.png" alt="">
More...
<h2 class="title">Title text 4</h2>
<div class="excerpt">
<div class="stars"><span>★</span><span>★</span><span>★</span><span>★</span><span>★</span></div>
<p class="whatever" href="#">Some text 4</p>
</div>
</div>
</div>
</div>
</div>
css
div.slider-wrap {
width: 640px;
height: 100%;
float: left
}
div#slider {
width: 80%;
max-width: 640px;
}
div#slider .jt_slides {
position: relative;
width: 400%;
margin: 0;
padding: 0;
font-size: 0;
text-align: left;
}
div#slider .jerslides {
width: 25%;
height: auto;
float:left
}
div#slider {
width: 100%;
max-width: 600px;
overflow: hidden;
margin: 26px auto 0;
}
#keyframes slidy {
0% {
left: 0%;
}
29% {
left: 0%;
}
33% {
left: -100%;
}
62% {
left: -100%;
}
67% {
left: -200%;
}
96% {
left: -200%;
}
100% {
left: -300%;
}
}
div#slider .jt_slides {
position: relative;
width: 400%;
margin: 0;
padding: 0;
font-size: 0;
left: 0;
text-align: left;
animation: 16s slidy infinite;
}
div#slider:hover .jt_slides {
/*transition: opacity .5s;*/
opacity: 0.9;
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
-o-animation-play-state: paused;
animation-play-state: paused;
}
.jerslides img {
margin-bottom: 20px
}
.jerslides .more-link {
float: right;
margin: 0 0 10px 10px;
}

The text is there, but it does not appear because it inherits the font-size: 0; from its ancestor element div#slider .jt_slides. Remove that rule and the text behaves as desired.
By the way, your CSS contains multiple rule-sets for some of the HTML elements, such as div#slider .jt_slides. Generally it's a good idea to consolidate duplicates into one rule-set. This can reduce confusion and make it easier to change CSS later on. This is because if a CSS rule is defined in only one of the rule-sets, it will still apply. For example here, since there are two rule-sets for div#slider .jt_slides and both contain the rule font-size: 0;, if you only remove font-size: 0; from one rule-set, it will still apply because it's still in the other rule-set. Consolidating would mean that when you remove font-size: 0; once, you know it's gone for good.

Related

Unable to use scroll bar beneath a fixed position div

There is a HTML table with a scrollbar, inside a div. There is another div with absolute position which overlaps with the table div. The problem is, table div's scroll bar is behind the absolute div (flying balloon animation), because of which I am unable to use it. Is there a way to use the scroll bar beneath the absolute div?
HTML:
#parent {
position: absolute;
top: 0;
right: 0;
z-index: 100;
width: 400px;
height: 100vh;
overflow: hidden;
}
.message {
position: absolute;
left: 0;
bottom: -120px;
height: 120px;
width: 120px;
background-color: white;
color: white;
line-height: 115px;
text-align: center;
font-family: Arial, sans-serif;
font-weight: bold;
border-radius: 60px;
animation: move 6s infinite linear;
opacity: 0.8;
}
.message:nth-child(2) {
left: 120px;
animation-delay: 2s;
}
.message:nth-child(3) {
left: 240px;
animation-delay: 4s;
}
#keyframes move {
0% {
bottom: -120px;
}
100% {
bottom: 100%;
}
}
<div class="container leaderboard">
<br>
<p class="text-right">Logged in as <strong>{{ player.user }}</strong> <img class="" src="url" /></p>
<div class="card">
<h6 class="card-header text-uppercase bg-dark text-white">Leaderboard</h6>
<div class="card-body">
<input type="text" id="leaderboard-search" onkeyup="leaderboardSearch()" placeholder="Search for names..">
<div class="overflow-wrap">
<table class="table leaderboard-table table-hover sortable">
<!-- Table here -->
</table>
</div>
</div>
</div>
<div id="parent">
<div class="message" style="background-image: url(sampleurl)"></div>
<div class="message" style="background-image: url(sampleurl)"></div>
<div class="message" style="background-image: url(sampleurl)"></div>
</div>
</div>

Insert arrow buttons

I have a webpage and a slider inside a picture. Right now the slider moves left and right on its own I want to insert clickable arrow keys that will navigate the user left and right.
<body>
<div id="slider">
<div class="container">
<div class="slide">
<h3>Slide 1</h3>
<p>#</p>
</div>
<div class="slide">
<h3>Slide 2</h3>
<p>#</p>
</div>
<div class="slide">
<h3>Slide 3</h3>
<p>#</p>
</div>
<div class="slide">
<h3>Slide 4</h3>
<p>#</p>
</div>
<div class="slide">
<h3>Slide 5</h3>
<p>#</p>
</div>
</div>
</div>
</body>
and this is the CSS
#slider, #slider .slide{
width: 500px;
height: 250px;
}
#slider {
overflow: hidden;
margin: 0 auto;
font-size: 1.2em;
}
#slider .container {
position: relative;
width: 9000px; /* Assign an insanely large width */
top: 0;
right: 0;
animation: slide-animation 25s infinite;
}
#slider .slide {
position: relative;
float: left;
box-sizing: border-box;
padding: 10px 20px;
}
#keyframes slide-animation {
0% {
opacity: 0;
right: 0;
}
11% {
opacity: 1;
right: 0;
}
22% { right: 100%; }
33% { right: 100%; }
44% { right: 200%; }
55% { right: 200%; }
66% { right: 300%; }
77% { right: 300%; }
88% {
opacity: 1;
right: 400%;
}
100% {
opacity: 0;
right: 400%;
}
}
Any help would be largely appreciated what code to use for arrow keys?
Where to insert div of arrow keys?
How to make the left and right keys work?
Even if you don't know the full answer any type of help is good.
You solely need to download some icons - therefore I recommend Feather icons - insert them as images and make them clickable for example by using JavaScript.

How can you perfectly centre a grid within a container without using CSS Grid or flexbox?

Okay, so I thought that the grid was perfectly aligned to the center, only to realise that it was a few pixels out. I completely stripped all of my attempts at centering and looked online but couldn't find anything.
I know I can use CSS Grids, Flexbox etc. but I am trying to learn how to create websites without using any aid. So I can learn the reasoning behind things.
Fiddle:
https://jsfiddle.net/8L9ye7nj/5/
Grid HTML:
<div class="box-wrapper">
<div class="box-container">
<div class="box" id="stethoscope">
<div class="box-label">
<p>Book an appointment</p>
</div>
</div>
<div class="box" id="prescription">
<div class="box-label">
<p>Request a repeat prescription</p>
</div>
</div>
<div class="box" id="group">
<div class="box-label">
<p>Join the Patient Group</p>
</div>
</div>
</div>
</div>
Grid CSS:
.box {
float: left;
width: 25%;
height: 300px;
background-color: #252625;
color: #FFF;
position: relative;
padding: 15px;
margin: 0.5%;
}
.box-label {
position: absolute;
bottom: 0;
text-align: center;
background-color: rgba(0,0,0,0.5);
width: 100%;
padding: 7px 0;
left: 0;
}
.box-label:hover {
animation: box-stretch 1s forwards ease-in-out;
cursor: pointer;
}
.box-container {
width: 90%;
}
.box-container::after {
content: "";
clear: both;
display: table;
}
.box-wrapper {
background-color: #B21645;
padding: 30px;
}
How can you divide the box and center them?
You can use calc to use mathematical expressions to calculate height, widths etc in css. You can divide the width by three here for the box.
.box {
display: inline-block;
width: calc(100% / 3);
}
Things to consider
Mind the space between inline-block elements. You can read more about
that here.
Avoid using floats as much as possible. Most layouts done with float can be achieved with inline-block. Floats are simply meant to take an element, put it to one side, and let other content flow around it. That’s all.
box-wrapper and box-container either one is only needed to wrap the contents inside.
Code Snippet
body {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
.box-wrapper {
background-color: #b21645;
padding: 20px;
}
.box {
position: relative;
display: inline-block;
width: calc(100% / 3);
padding: 0 10px;
height: 300px;
overflow: hidden;
}
.box img {
height: 100%;
width: 100%;
object-fit: cover;
object-position: left top;
}
.box-label {
position: absolute;
bottom: 0;
width: calc(100% - 20px);
text-align: center;
background-color: rgba(0, 0, 0, .6);
padding: 10px 0;
transition: padding 0.3s;
}
.box-label:hover {
padding: 25px 0;
}
.box-label p {
font-family: Helvetica;
color: white;
font-size: 20px;
}
<div class="box-wrapper">
<div class="box">
<img src="https://images.unsplash.com/photo-1509027572446-af8401acfdc3?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=ef8f839186c5a6055d2802005b575194&auto=format&fit=crop&w=500&q=60" alt="" />
<div class="box-label">
<p>Some Title Here</p>
</div>
</div><div class="box">
<img src="https://images.unsplash.com/photo-1509027572446-af8401acfdc3?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=ef8f839186c5a6055d2802005b575194&auto=format&fit=crop&w=500&q=60" alt="">
<div class="box-label">
<p>Some Title Here</p>
</div>
</div><div class="box">
<img src="https://images.unsplash.com/photo-1509027572446-af8401acfdc3?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=ef8f839186c5a6055d2802005b575194&auto=format&fit=crop&w=500&q=60" alt="">
<div class="box-label">
<p>Some Title Here</p>
</div>
</div>
</div>

How do I add text to my image slider?

Hello guys I would like to know how can I add text in my image slider. I would like to add text to each image. I could do it in Photoshop, but I wont to be able to edit the text in the HTML in future in case it needs changing. How would I go about doing that?
#keyframes slidy {
0% { left: 0%; }
20% { left: 0%; }
25% { left: -115%; }
45% { left: -115%; }
50% { left: -225%; }
70% { left: -225%; }
75% { left: -335%; }
95% { left: -335%; }
100% { left: -445%; }
}
body { margin: 0; }
div#slider { overflow: hidden; }
div#slider figure img { width: 22%; float: left; }
div#slider figure {
position: relative;
width: 500%;
height: 34px;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 30s slidy infinite;
}
#slider {
max-width: 75%;
left: 12.5%;
max-height: 55%;
}
</div>
previously -->
<div class="container center-block">
<div class="col-xs-12" id="slider">
<figure>
<img src="imgs/rdp.jpg" class="img-responsive" />
<img src="imgs/wires.jpg" class="img-responsive" />
<img src="imgs/speed.jpg" class="img-responsive" />
<img src="imgs/tech.jpg" class="img-responsive" />
</figure>
</div>
</div>

CSS Diagonal Image Overlap that expands to full width when hovered

Hi I'm trying to create a collage of three images, like the concept shown in this site: https://codepen.io/zacharybrady/pen/aGmFp
The HTML:
<div class="container">
<div class="diagonal" id="d0">
<img src="http://www.shortpacked.com/comics/2013-02-08-prologue.png" />
<p class="overlay">
TEST
</p>
</div>
<div class="diagonal" id="d1">
<img src="http://www.questionablecontent.net/comics/2381.png" />
<p class="overlay">
TEST
</p>
</div>
<div class="diagonal" id="d2">
<img src="http://www.shortpacked.com/comics/2005-01-17-bow-before-your-master.gif" />
<p class="overlay">
TEST
</p>
</div>
<div class="diagonal" id="d3">
<img src="http://www.questionablecontent.net/comics/2021.png" />
<p class="overlay">
TEST
</p>
</div>
<div class="diagonal" id="d4">
<img src="http://www.shortpacked.com/comics/2009-03-27-fourohfour.png" />
<p class="overlay">
TEST
</p>
</div>
</div>
THE CSS:
#import "compass/css3";
#import "compass/css3";
body{
background: blue;
}
.container{
width: 800px;
height: 400px;
background: white;
overflow: hidden;
position: relative;
margin-left: 100px;
.diagonal{
height: 1200px;
width: 200px;
overflow: hidden;
#include rotate(25deg);
position: absolute;
top: -200px;
img{
#include rotate(-25deg);
margin-top: -100px;
margin-left: -200px;
}
.overlay{
#include rotate(-25deg);
height: 1200px;
width: 800px;
position: absolute;
top: -50px;
left: 0;
background: black;
opacity: 0;
color: white;
-webkit-transition: opacity .5s;
vertical-align: middle;
text-align: center;
&:hover{
opacity: .8;
}
}
&#d0{
left: -180px;
}
&#d1{
left: 40px;
}
&#d2{
left: 260px;
}
&#d3{
left: 480px;
}
&#d4{
left: 700px;
}
}
}
Question: How can I add additional transitions that when a specific image is hovered, it will expand to its full width?
PLEASE DON'T MARK this as duplicate or close this for having ambiguous question, because I know and you know the question there is clear and understandable.
You could change the z-axis on hover, so that the full image comes to the front.