change picture size in slideshow in CSS and HTML - html

I am currently making a website and when I view the slideshow its too big is there any way of changing the size of it? I am using HTML and CSS made in visual studio and here is an image of the site 50% zoomed out slideshow
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = x.length
}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-opacity-off", "");
}
x[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " w3-opacity-off";
}
.mySlides {
display: none
}
.demo {
cursor: pointer
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"/>
<div class="w3-content" style="max-width:1200px">
<img class="mySlides" src="https://cdn.pixabay.com/photo/2018/09/07/17/50/fruit-3661159_960_720.jpg" style="width:100%">
<img class="mySlides" src="https://cdn.pixabay.com/photo/2016/10/11/12/37/piano-keys-1731467_960_720.jpg" style="width:100%">
<img class="mySlides" src="https://cdn.pixabay.com/photo/2017/11/14/18/31/mushroom-2949539_960_720.jpg" style="width:100%">
<div class="w3-row-padding w3-section">
<div class="w3-col s4">
<img class="demo w3-opacity w3-hover-opacity-off" src="https://cdn.pixabay.com/photo/2018/09/07/17/50/fruit-3661159_960_720.jpg" style="width:100%" onclick="currentDiv(1)">
</div>
<div class="w3-col s4">
<img class="demo w3-opacity w3-hover-opacity-off" src="https://cdn.pixabay.com/photo/2016/10/11/12/37/piano-keys-1731467_960_720.jpg" style="width:100%" onclick="currentDiv(2)">
</div>
<div class="w3-col s4">
<img class="demo w3-opacity w3-hover-opacity-off" src="https://cdn.pixabay.com/photo/2017/11/14/18/31/mushroom-2949539_960_720.jpg" style="width:100%" onclick="currentDiv(3)">
</div>
</div>
</div>

Looking for something like this? I dropped the W3.css Library. This example is on W3schools.com. From my current location I cannot access the photos you posted so I had to use different example photos.
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > slides.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
}
body {
font-family: Arial;
margin: 0;
}
* {
box-sizing: border-box;
}
img {
vertical-align: middle;
}
/* Position the image container (needed to position the left and right arrows) */
.container {
position: relative;
max-width: 1280px;
margin: 0 auto;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* Add a pointer when hovering over the thumbnail images */
.cursor {
cursor: pointer;
}
.row:after {
content: "";
display: table;
clear: both;
}
/* Six columns side by side */
.column {
float: left;
width: 33.33%;
padding: 1%;
}
/* Add a transparency effect for thumnbail images */
.demo {
opacity: 0.6;
}
.active,
.demo:hover {
opacity: 1;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<h2 style="text-align:center">Slideshow Gallery</h2>
<div class="container" >
<div class="mySlides">
<img src="https://www.w3schools.com/howto/img_woods_wide.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="https://www.w3schools.com/howto/img_5terre_wide.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="https://www.w3schools.com/howto/img_mountains_wide.jpg" style="width:100%">
</div>
<br>
<div class="row">
<div class="column">
<img class="demo cursor" src="https://www.w3schools.com/howto/img_woods.jpg" style="width:100%" onclick="currentSlide(1)" alt="The Woods">
</div>
<div class="column">
<img class="demo cursor" src="https://www.w3schools.com/howto/img_5terre.jpg" style="width:100%" onclick="currentSlide(2)" alt="Cinque Terre">
</div>
<div class="column">
<img class="demo cursor" src="https://www.w3schools.com/howto/img_mountains.jpg" style="width:100%" onclick="currentSlide(3)" alt="Mountains and fjords">
</div>
</div>
</div>

You can set a fixed height /width for your images however you risk the images becoming skewed. I set a fixed height below, and the images will display within the window, and the thumbs will all be of the same height, however you'd be better off starting with images that are of similar dimensions and using % or vertical height (vh) to size the images smaller as appropriate to what you want.
Hope this helps
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = x.length
}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-opacity-off", "");
}
x[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " w3-opacity-off";
}
body {
padding: 0;
width:900px;
max-height:100%;
overflow-y:hidden;
}
.w3-content {
max-width:600px;
max-height: 50vh!important;
margin:0 auto;
}
.mySlides {
display: none;
width: 100%;
height:450px;
}
.demo {
cursor: pointer;
height:150px;
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet" />
<body>
<div class="w3-content">
<img class="mySlides" src="https://cdn.pixabay.com/photo/2018/09/07/17/50/fruit-3661159_960_720.jpg">
<img class="mySlides" src="https://cdn.pixabay.com/photo/2016/10/11/12/37/piano-keys-1731467_960_720.jpg">
<img class="mySlides" src="https://cdn.pixabay.com/photo/2017/11/14/18/31/mushroom-2949539_960_720.jpg">
<div class="w3-row-padding w3-section">
<div class="w3-col s4">
<img class="demo w3-opacity w3-hover-opacity-off" src="https://cdn.pixabay.com/photo/2018/09/07/17/50/fruit-3661159_960_720.jpg" style="width:100%" onclick="currentDiv(1)">
</div>
<div class="w3-col s4">
<img class="demo w3-opacity w3-hover-opacity-off" src="https://cdn.pixabay.com/photo/2016/10/11/12/37/piano-keys-1731467_960_720.jpg" style="width:100%" onclick="currentDiv(2)">
</div>
<div class="w3-col s4">
<img class="demo w3-opacity w3-hover-opacity-off" src="https://cdn.pixabay.com/photo/2017/11/14/18/31/mushroom-2949539_960_720.jpg" style="width:100%" onclick="currentDiv(3)">
</div>
</div>
</div>
</body>

Related

How to create right and left buttons to move product carousel in jQuery?

Investigating and, putting together my code little by little, I have achieved a carousel with the mouseup function that allows me to move the products by pressing the left button of the mouse without releasing it, so far it goes very well, well sometimes it remains as stalled, that is, without having pressed if I move the pointer moves the products.
What I want to achieve in my code is to be able to integrate two buttons, one right and one left, to also be able to move the products of the carousel in that way. How can I achieve it, can you explain to me?
var direction_slider = "up";
var current_step = 0;
var scroll_product = false;
var scroll = -1;
$(function(){
// vars for clients list carousel
var $product_carousel = $('.slider');
var products = $product_carousel.children().length;
var product_width = (products * 140); // 140px width for each client item
$product_carousel.css('width',product_width);
var rotating = true;
//var product_speed = 1800;
//var see_products = setInterval(rotateClients, product_speed);
$(document).on({
mouseenter: function(){
rotating = false; // turn off rotation when hovering
},
mouseleave: function(){
rotating = true;
}
}, '#carousel');
$product_carousel.on("mousedown", function(e) {
scroll_product = true;
scroll = e.pageX;
event.preventDefault();
}).on("mouseup", function(e) {
scroll_product = false;
var num = Math.floor(Math.abs(scroll - e.pageX) / 140);
var dir = scroll - e.pageX < 0 ? "up" : "down";
for (var x = 0; x < num; x++) {
var $first = $('.slider .item:first');
var $last = $('.slider .item:last');
if (dir == "up") {
$last.prependTo(".slider");
} else {
$first.appendTo(".slider");
}
}
$(".slider").css("transform", "translate(0, 0)")
}).on("mousemove", function(e) {
if (scroll_product) {
$(".slider").css("transform", "translate(" + ( e.pageX - scroll ) +"px, 0)")
}
});
});
.carousel {
margin: 0 auto;
padding: 1em;
width: 100%;
max-width: 1170px;
margin-left: auto;
overflow: hidden;
}
.slider {
width: 100% !important;
display: flex;
}
.item {
display: inline-table;
width: 280px;
height: 325px;
margin: 0.5em;
border: 1px solid #ccc;
}
a {
color: #8563CF;
text-decoration: none;
font-weight: 100;
}
.thumbnail {
height: 150px;
position: relative;
}
.thumbnail img {
height: 100%;
width: 100%;
object-fit: cover;
object-position: 50% 15%;
}
img {
border: 0;
height: auto;
max-width: 100%;
vertical-align: middle;
}
.p1em {
padding: 1em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div class="carousel">
<div id="carousel">
<div class="slider" style="width: 280px; transform: translate(0px, 0px);">
<div class="item product">
<a href="#">
<div class="thumbnail image">
<img src="https://i.ytimg.com/vi/ZxrUVuOqsy0/maxresdefault.jpg">
</div>
<div class="box p1em">
<div class="heading ellipsis">
<h3>Prueba 1</h3>
</div>
<div class="author">
<span></span>
</div>
<div class="price right">
<p>
<label></label>
<em class="item-price">$40.130,00</em>
</p>
</div>
</div>
</a>
</div> <div class="item product">
<a href="#">
<div class="thumbnail image">
<img src="https://i.ytimg.com/vi/ZxrUVuOqsy0/maxresdefault.jpg">
</div>
<div class="box p1em">
<div class="heading ellipsis">
<h3>Curso de PHP 8 básico, intermedio y, avanzado. </h3>
</div>
<div class="author">
<span>Acaded</span>
</div>
<div class="purchased items-center">
<button>Ir al curso</button>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
The goal here is to shift the order of elements to the left or right. With jQuery this is exceptionally easy.
The logic is as so:
To shift the order to the right, select the last item, delete it, then insert before the first item
To shift the order to the left, select the first item, delete it, then insert after the last item
To achieve this, we attach a click event listener to each respective button. We select all the slider items with the selector $('.item.product'), use last() and first() to get the first and last items, and the remove() function to delete the element. Then, to reorder, we use jQuery's insertBefore() and insertAfter().
This is the result:
$('#right').click(function() {
$('.item.product').last().remove().insertBefore($('.item.product').first());
})
$('#left').click(function() {
$('.item.product').first().remove().insertAfter($('.item.product').last());
})
And the rest is just a matter of styling (note: uses Material Icons for the arrow icons). Define two button elements;
<button id="left" class="nav-btn"><i class="material-icons">chevron_left</i></button>
<button id="right" class="nav-btn"><i class="material-icons">chevron_right</i></button>
The "chevron_right" and "chevron_left" are icon names | List of Icons
Set their position to fixed so that their position isn't lost when the user scrolls. Set the top attribute to calc(50vh - 50px), where 50vh is half the height of the viewport and 50px is the height of the button (to make it exactly in the "center").
A full example (best viewed in full page mode):
var direction_slider = "up";
var current_step = 0;
var scroll_product = false;
var scroll = -1;
$(function() {
$('#right').click(function() {
$('.item.product').last().remove().insertBefore($('.item.product').first());
})
$('#left').click(function() {
$('.item.product').first().remove().insertAfter($('.item.product').last());
})
var $product_carousel = $('.slider');
var products = $product_carousel.children().length;
var product_width = (products * 140);
$product_carousel.css('width', product_width);
var rotating = true;
$(document).on({
mouseenter: function() {
rotating = false;
},
mouseleave: function() {
rotating = true;
}
}, '#carousel');
$product_carousel.on("mousedown", function(e) {
scroll_product = true;
scroll = e.pageX;
event.preventDefault();
}).on("mouseup", function(e) {
scroll_product = false;
var num = Math.floor(Math.abs(scroll - e.pageX) / 140);
var dir = scroll - e.pageX < 0 ? "up" : "down";
for (var x = 0; x < num; x++) {
var $first = $('.slider .item:first');
var $last = $('.slider .item:last');
if (dir == "up") {
$last.prependTo(".slider");
} else {
$first.appendTo(".slider");
}
}
$(".slider").css("transform", "translate(0, 0)")
}).on("mousemove", function(e) {
if (scroll_product) {
$(".slider").css("transform", "translate(" + (e.pageX - scroll) + "px, 0)")
}
});
});
/* button integration styling (start) */
#left {
left: 10px;
}
#right {
right: 10px;
}
.nav-btn {
position: fixed;
top: calc(50vh - 50px);
z-index: 100;
z-index: 100;
height: 50px;
width: 50px;
border-radius: 50%;
cursor: pointer;
background-color: white;
box-shadow: 0 0 1px black;
transition: 0.2s;
}
.nav-btn:hover {
background-color: #d1d1d1;
}
/* button integration styling (end) */
.carousel {
margin: 0 auto;
padding: 1em;
width: 100%;
max-width: 1170px;
margin-left: auto;
overflow: hidden;
}
.slider {
width: 100% !important;
display: flex;
}
.item {
display: inline-table;
width: 280px;
height: 325px;
margin: 0.5em;
border: 1px solid #ccc;
}
a {
color: #8563CF;
text-decoration: none;
font-weight: 100;
}
.thumbnail {
height: 150px;
position: relative;
}
.thumbnail img {
height: 100%;
width: 100%;
object-fit: cover;
object-position: 50% 15%;
}
img {
border: 0;
height: auto;
max-width: 100%;
vertical-align: middle;
}
.p1em {
padding: 1em;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div class="carousel">
<button id="left" class="nav-btn"><i class="material-icons">chevron_left</i></button>
<button id="right" class="nav-btn"><i class="material-icons">chevron_right</i></button>
<div id="carousel">
<div class="slider" style="width: 280px; transform: translate(0px, 0px);">
<div class="item product">
<a href="#">
<div class="thumbnail image">
<img src="https://i.ytimg.com/vi/ZxrUVuOqsy0/maxresdefault.jpg">
</div>
<div class="box p1em">
<div class="heading ellipsis">
<h3>Prueba 1</h3>
</div>
<div class="author">
<span></span>
</div>
<div class="price right">
<p>
<label></label>
<em class="item-price">$40.130,00</em>
</p>
</div>
</div>
</a>
</div>
<div class="item product">
<a href="#">
<div class="thumbnail image">
<img src="https://i.ytimg.com/vi/ZxrUVuOqsy0/maxresdefault.jpg">
</div>
<div class="box p1em">
<div class="heading ellipsis">
<h3>Curso de PHP 8 básico, intermedio y, avanzado. </h3>
</div>
<div class="author">
<span>Acaded</span>
</div>
<div class="purchased items-center">
<button>Ir al curso</button>
</div>
</div>
</a>
</div>
<div class="item product">
<a href="#">
<div class="thumbnail image">
<img src="https://www.gravatar.com/avatar/0fdacb141bca7fa57c392b5f03872176?s=96&d=identicon&r=PG&f=1">
</div>
<div class="box p1em">
<div class="heading ellipsis">
<h3>Spectric</h3>
</div>
<div class="author">
<span>Spectric</span>
</div>
<div class="purchased items-center">
<button>Check out</button>
</div>
</div>
</a>
</div>
</div>
</div>
</div>

How to resize text for mobile responsiveness

I am trying to create my website and input a short animation of text sliding every 0.4 seconds to change to another text. It's like an image gallery, but just text instead. I put this html code together from ws3school hence, some of the code inside might not make sense but it still runs perfectly fine.
I do not know how to code and I am just trying to make sense of what I see, some of the code below may seem a little inappropriate or weird to be there, I'm just trying to make it all work.
The issue I have is that it is not mobile-friendly, so when I open the website on a smaller screen, the font size does not change accordingly. I think I managed to fix the border size but not the font size. Can someone help me?
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.div1 {
max-width: 460px;
height: 170px;
padding: 40px;
border: 1px solid black;
text-align: center;
font-size: 65px;
font-family: courier;
}
/* On smaller screens, decrease text size */
#media only screen and (max-width: 300px) {
.text {
max-font-size: 20px
}
}
</style>
</head>
<body>
<div class="div1">
<div class="mySlides w3-container w3-xlarge w3-transparent">
<p>marketer</p>
</div>
<div class="mySlides w3-container w3-xlarge w3-transparent">
<p>creator</p>
</div>
<div class="mySlides w3-container w3-xlarge w3-transparent">
<p>innovator</p>
</div>
<div class="mySlides w3-container w3-xlarge w3-transparent">
<p>collaborator</p>
</div>
<script>
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {
slideIndex = 1
}
x[slideIndex - 1].style.display = "block";
setTimeout(carousel, 400);
}
</script>
</body>
</html>
Try:
#media only screen and (max-width: 300px) {
.div1 {
font-size: 20px;
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div.example {
max-width: 460px;
height: 170px;
padding: 40px;
border: 1px solid black;
text-align: center;
font-size: 65px;
font-family: courier;
}
#media screen and (min-width: 601px) {
div.example {
font-size: 65px;
}
}
#media screen and (max-width: 600px) {
div.example {
font-size: 30px;
}
}
</style>
</head>
<body>
<div class="example">
<p>marketer</p>
</div>
<div class="example">
<p>creator</p>
</div>
<div class="example">
<p>innovator</p>
</div>
<div class="example">
<p>collaborator</p>
</div>
</div>
<script>
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("example");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].style.display = "block";
setTimeout(carousel, 400);
}
</script>
</body>
</html>
You can use relative size like vw to make it responsive. In combination with calc you can say that minimal font size should be for example 20px and for bigger screens it should be bigger thanks the vw unit.
font-size: calc(20px + 0.4vw);
You can use this outside the media query.
Try this code:
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {
slideIndex = 1
}
x[slideIndex - 1].style.display = "block";
setTimeout(carousel, 400);
}
.div1 {
max-width: 460px;
height: 170px;
padding: 40px;
border: 1px solid black;
text-align: center;
font-size: 65px;
font-family: courier;
}
#media screen and (max-width: 300px) {
.div1 p {
font-size: 20px
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="div1">
<div class="mySlides">
<p>marketer</p>
</div>
<div class="mySlides">
<p>creator</p>
</div>
<div class="mySlides">
<p>innovator</p>
</div>
<div class="mySlides">
<p>collaborator</p>
</div>
</div>
</body>
</html>

Why do my items with javascript go in front of my Nav

My nav keeps going behind any items I have that contain javascript.
I've tried changing the z-index of both items but I'm not sure how else to fix it
http://flavorsbyj.site/#Reviews
View this site and scroll down... This also happens if you scroll up a bit with the pictures slideshow. Both which contain Javascript
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {
slideIndex = 1
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
setTimeout(showSlides, 5000);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="slideshow-container col-6 col-m-12" style="background-color:#E7E7E7; border-radius: 1vh;">
<div class="mySlides fade">
<img alt="Event2" src="Images/E2.1.jpg" style=" border-radius: 1vh;" class="col-20 col-m-0">
<img alt="Event2" src="Images/E2.1.jpg" style=" border-radius: 1vh;" class="col-0 col-m-20">
</div>
<div class="row" id="navbar" style="position: fixed; width: 100%;">
<div class="col-m-4 col-4 dropdown-right">
<span id="bar" style="font-size:9vh;cursor:pointer; color: #232323; margin-left: 10px; padding: 10px; text-shadow: 1px 2px white" onclick="openNav()">☰</span>
</div>
<div class="col-5 col-m-4"> </div>
<div class="col-4 col-m-4"><img alt="Logo" src="Images/Logo.jpg" class="col-9 col-m-20" style="height: 13vh;"></div>
<div class="col-2 col-m-0"> </div>
<div class="col-m-0 col-5">
<a href="Home.html" style=" text-align: right; margin-top: -1vh;">
<img alt="RampCert" src="Images/Ramp.png" class="col-20 col-m-20" style="height: 10vh;">
</a>
</div>
<div class="col-m-7 col-0">
<a href="#Home" style="text-align: right; margin-top: -1vh;">
<img alt="RampCert" src="Images/Ramp.png" class="col-20 col-m-20" style="height: 10vh;">
</a>
</div>
</div>
You just need to add a z-index to your #navbar then it will be front of your content.
Example:
#navbar {
z-index: 999 //or any value bigger than 0
}
This is happening because of the z-index value. Just replace your #navbar inline-css with following css and it will work as expected
#navbar {
z-index:9999; /*Change this value accordingly */
}
OR
<div class="row" id="navbar" style="position: fixed;width: 100%; z-index: 9999; ">
Hope it helps.
Solution is z-index for sure as there is already answer by couple of other people.
I would say while using the z-index you must have to make sure which element you want on the top on based on that only you can provide the z-index not just the random number to bring up like 999. z-index work like layers.
In your problem z-index:2 will resolve the issue too.
#navbar {
z-index: 2;
}

Class is not being right using relative property

I have declared a class and positioned it absolute and when I declare another class and position another as relative and it's not working.
Here is 1st class:
<p class="slidshow">
<img class="mySlides" src="1.jpg" width="1000px" height="500px">
<img class="mySlides" src="2.jpg" width="1000px" height="500px">
<img class="mySlides" src="3.jpg" width="1000px" height="500px">
<img class="mySlides" src="4.jpg" width="1000px" height="500px">
<script type="text/javascript">
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].style.display = "block";
setTimeout(carousel, 4000); // Change image every 2 seconds
}
Here it's css:
.slidshow{
position: absolute;
top: 130px;
right: 150px;
}
Here is second class:(it's just a sample)
<div class="cont">
<a id="contact">PHONE</a>
</div>
Here is it's css:
.cont{
position: relative;
top: 10px;
right: 10px;
}
The second class appears left to to first class.
I think you should read it first so you can better understand the css positions.
It's not about the exact solution it's about getting the basics that will lead you to build better layouts in future so please go through this article:
https://medium.freecodecamp.org/how-to-use-the-position-property-in-css-to-align-elements-d8f49c403a26

navigation bar not showing when uploaded online

kind sir's does anybody know why my navigation bar is not showing when i upload it in a free web host (x10hosting and 000webhost) but when i run it in localhost its perfectly working.
this is when i run it in localhost
and this what happens when i run it online
this is the html code
<?php
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(E_ERROR | E_PARSE);
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<nav class="clearfix">
<ul class="clearfix">
<li><img src="img\home.png" style="margin-bottom:-2px; margin-right:3px; width:16px; height:16px;">Home</li>
<li><img src="img\speakers.png" style="margin-bottom:-1px; margin-right:4px; width:15px; height:13px;">Speakers</li>
<li><img src="img\about.png" style="margin-bottom:-1px; margin-right:3px; width:13px; height:12px;">About</li>
<li><img src="img\contact.png" style="margin-bottom:-2px; margin-right:6px; width:13px; height:14px;">Contact</li>
<li><img src="img\reservation.png" style="margin-bottom:-2px; margin-right:5px; width:14px; height:13px;">Reservation</li>
<li><img src="img\signOut.png" style="margin-bottom:-2px; margin-right:6px; width:14px; height:14px;">Sign Out</li>
<li><img src="img\user.png" style="margin-bottom:-1px; margin-right:6px; width:13px; height:12px;"><?php echo $_SESSION['firstname']; ?></li>
<li><img src="img\signUp.png" style="margin-bottom:-1px; margin-right:6px; width:13px; height:11px;">Sign Up</li>
<li><img src="img\signIn.png" style="margin-bottom:-2px; margin-right:6px; width:14px; height:13px;">Sign In</li>
<li><img src="img\admin.png" style="margin-bottom:-3px; margin-right:6px; width:15px; height:16px;">Admin control</li>
</ul>
Speaker Reservation
</nav>
<div class="slideshow-container">
<div class="mySlides fade">
<img id="img1" src="img/homepage-image1.jpg">
<div class="text"></div>
</div>
<div class="mySlides fade">
<img id="img2" src="img/homepage-image2.jpg">
<div class="text"></div>
</div>
<div class="mySlides fade">
<img id="img3" src="img/homepage-image3.jpg">
<div class="text"></div>
</div>
<div id="dots">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div id="index-welcome"><p>Welcome to Online Speaker Reservation. We are an organization established in 2005 by Rey Vibal, which engages the skills of performing artists directors and writers for the purpose of tuition in the performing arts, theatrical and film production, corporate training, wellness and sharing methodologies.</p></div>
<div id="footer" >Copyright 2017</div>
<script>
$(function()
{
var pull = $('#pull');
menu = $('nav ul');
menuHeight = menu.height();
$(pull).on('click', function(e)
{
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function()
{
var w = $(window).width();
if(w > 320 && menu.is(':hidden'))
{
menu.removeAttr('style');
}
});
});
</script>
<script>
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex> slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 4000);
}
</script>
<script>
function ifAdmin()
{
document.getElementById("signIn").style.display = "none";
document.getElementById("signUp").style.display = "none";
document.getElementById("signOut").style.display = "block";
document.getElementById("adminControl").style.display = "block";
}
</script>
<script>
function ifNotAdmin()
{
document.getElementById("signIn").style.display = "none";
document.getElementById("signUp").style.display = "none";
document.getElementById("signOut").style.display = "block";
document.getElementById("adminControl").style.display = "none";
}
</script>
<script>
function ifNotLogin()
{
document.getElementById("user").style.display = "none";
document.getElementById("signOut").style.display = "none";
document.getElementById("adminControl").style.display = "none";
}
</script>
<?php
if (isset($_SESSION['signedIn']) && $_SESSION['signedIn'] == true)
//if login
{
if($_SESSION['type'] == 1)
{
echo "<script type='text/javascript'>ifAdmin();</script>";
}
elseif($_SESSION['type'] == 0)
{
echo "<script type='text/javascript'>ifNotAdmin();</script>";
}
}
//if not login
else
{
echo "<script type='text/javascript'>ifNotLogin();</script>";
}
?>
</body>
</html>
this is the css codes
/*navigation bar*/
nav
{
height: 60px;
width: 100%;
background: #342E2D;
font-size: 10pt;
font-family: 'PT Sans', Arial, sans-serif;
font-weight: bold;
position: relative;
}
nav ul
{
padding: 0;
margin: auto;
width: 100%;
height: 60px;
}
nav li
{
display: inline;
}
nav a
{
color: #fff;
display: inline-block;
width: 100px;
text-align: center;
text-decoration: none;
line-height: 60px;
text-shadow: 1px 1px 0px #283744;
}
nav li a
{
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
nav li:last-child a
{
border-right: 0;
}
nav a:hover, nav a:active
{
background-color: #1E1D1C;
}
nav a#pull
{
display: none;
}
/* Clearfix */
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
#signIn, #signUp, #signOut, #adminControl, #user
{
float:right;
}
#adminControl
{
width:130px;
}
Your code looks fine to me Make sure to clear cache u can achive this by
Option1:
Try opening the browser in Incognito(chrome) mode.
CTRL + P
private(IE)
CTRL + N
Option2
Just clear the browsers cache.
I had a cache problem few times using webhost00
It appears like the CSS styling isn't loading at all. Check the location of your CSS file on your webhost against the stylesheet link in your HTML file.