Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to stack images destined to be displayed as a slideshow?

Explorer ,
Feb 01, 2025 Feb 01, 2025

Hi,
I wonder if anyone could offer a solution to this:

I added images that change automatically as a slide show on a page, using the descriptive found here:

https://stackoverflow.com/questions/46519126/how-to-randomize-the-slideshow-image-in-html

The action works well. But the problem is that the 4 images, 350px wide, appear side by side in the page layout in Dreamweaver, and blow up the page layout. Adding more images would just be impossible.

I suspect that the action described above is based on images linked to an external website and not hosted locally, and therefore they do not show up in the layout. Mine are on my computer.

 

I wonder if there is a way to stack images in the preview, as there is for instance a possibility to reduce the code to one line for a set of lines in code view? I'm not very knowledgeable I must say.

 

Just as a note, although a Creative Cloud user, I'm still using DW CS6 due to many Spry collapsible panels in my pages.

 

Thank you.
Paul

 

483
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 01, 2025 Feb 01, 2025

OK. Start by fixing these 30 HTML Code Validation Errors

https://validator.w3.org/nu/?doc=https%3A%2F%2Fpaulschilliger.com%2FSanstitre-1.html

And 7 invalid CSS Properties

https://jigsaw.w3.org/css-validator/validator?profile=css3&warning=0&uri=https%3A%2F%2Fpaulschilliger.com%2FSanstitre-1.html

 

Or simply create a new, blank document. 

Go to File > New > New Document > HTML > HTML5.

Hit the CREATE button.

 

image.pngexpand image

 

In CODE view, Remove & Replace everything with this responsive layout code.

<!doctyp
...
Translate
Community Expert ,
Feb 01, 2025 Feb 01, 2025

There does not seem to be a problem using the code as per StackOverflow.

 

https://www.youtube.com/watch?v=CkHNoNfzZak

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Thank you, I appreciate your effort in posting this!

Maybe I will add some screenshots later to explain what happens in my layout.

I suspect that I am building with blocks that are not supposed to work together, hence the stretch.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Capture d’écran 2025-02-01 à 19.01.31.pngexpand image

This is a quick sketch to show the problem I am running into. Images added to the container are displayed side by side. I cannot use a line breaker to distribute them in additional lines. Once viewed in the browser, everything is fine though and only the right frame in this case is displayed, with changing images.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

What's the URL to your site where it's not working?

 

By default, <div> tags are treated as block-level elements by browsers.

If yours are displaying inline, then something else in your code is making that happen.  That's not the slideshow's problem. That's a problem with where you're inserting it.  Try testing the slideshow on a fresh, blank HTML page.

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Oh I'm sorry, I may have not explained things correctly since all who read my question understand that it's not working. The script is actually working perfectly. My question is with fitting this slide show container in the DW page locally, without stretching the layout. The page still works and displays at the fixed width in the browser, but in the composition or layout view it overflows from the 800 px set for the page to quickly double the page width.

I wonder if there would be a way to add images to the slideshow without having that. Maybe just having them linked to the remote server as in the Stackoverflow example ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Post your URL so we can see what's going on. 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Thank you Nancy, here is a link. But as I mentioned, you probably won't see what is problematic unless you copy the contents in a blank page in DW and perhaps link substitute images, IMHO.

https://paulschilliger.com/Sanstitre-1.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

OK. Start by fixing these 30 HTML Code Validation Errors

https://validator.w3.org/nu/?doc=https%3A%2F%2Fpaulschilliger.com%2FSanstitre-1.html

And 7 invalid CSS Properties

https://jigsaw.w3.org/css-validator/validator?profile=css3&warning=0&uri=https%3A%2F%2Fpaulschillige...

 

Or simply create a new, blank document. 

Go to File > New > New Document > HTML > HTML5.

Hit the CREATE button.

 

image.pngexpand image

 

In CODE view, Remove & Replace everything with this responsive layout code.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Responsive Layout, CSS Grid</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
width: 85%; 
margin: 0 auto;
background-color:antiquewhite;
color:#372602; 
font-family: Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif;
font-size: calc(16px + 1vw);
line-height: calc(1.1em + 0.5vw);
}

/**linked text**/
a:link {color:darkred; text-decoration:none}
a:visited {color:darkgray;}
a:hover, a:active, a:focus {color:crimson; text-decoration: underline}

.grid-container { 
display: grid;
grid-column-start: col 1;
grid-gap: 5px;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-template-rows: repeat(auto-fit, 1fr);
}

.grid-container img {
vertical-align: baseline;
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<main>
<div class="row">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum consequuntur numquam eaque deserunt repudiandae optio dolores soluta voluptate quaerat, incidunt assumenda aperiam vitae unde reprehenderit, voluptas minima ducimus tempore, etc.</p>
</div>
</main>

<h2>CSS Grid Test</h2>
<div class="grid-container">
<!--unordered list-->
<ul>
<li><a href="#">Linked Text</a></li> 
<li><a href="#">Linked Text</a></li> 
<li><a href="#">Linked Text</a></li>
</ul>
<!--Slideshow Slides-->
<div class="slideshow-container">
<img class="mySlides fade" src="https://dummyimage.com/650x490/000/EAE" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/FFF/555" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/000/F0F" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/FFF/F00"  alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/000/FF0" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/000/EAE" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/FFF/555" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/000/F0F" alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/FFF/F00"  alt="placeholder">

<img class="mySlides fade" src="https://dummyimage.com/650x490/000/FF0" alt="placeholder">
<!--end slideshow--></div>
<!--end container--></div>

<!--slideshow script-->
<script>
var slideIndex = 0;
showSlides();
function showSlides() {
    var i;
    var slides = document.getElementsByClassName("mySlides");
    for (i = 0; i < slides.length; i++) {
        slides[i].style.display = "none"; 
    }
    slideIndex++;
    if (slideIndex> slides.length) {slideIndex = 1} 
    slides[slideIndex-1].style.display = "block"; 
    setTimeout(showSlides, 6000); // Change image every 6 seconds
}
</script>
</body>
</html>

 

This works in LIVE or DESIGN View in Dreamweaver.

Live ViewLive Viewexpand image

 

No tables were used & no animals were harmed.

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Thank you for your hard work!

Yes, I've been dragging this site around for 20 years and it's certainly outdated and flawed...

I'm going to have to rebuild it on a current and healthy basis. And not forget the CSS. This will take me some time.

But just to encourage us, copying and pasting my page into a new HTML5 document solved the image piling problem! They now display in rows of 3 and no longer mess up the layout. So there was indeed some mismatch.

So great to have experts help and advice. Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2025 Feb 02, 2025
quote

copying and pasting my page into a new HTML5 document solved the problem...

By alpshiker

==========

Right.  Because your previous code contained 37 errors -- denoted by the red X

To render pages correctly, use valid code -- green checkmark ✓.

 

Bookmark these tutorials for reference:

- https://www.w3schools.com/html/
- https://www.w3schools.com/css/
- https://www.w3schools.com/js/

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 09, 2025 Feb 09, 2025

By the way, since friendly experts are ready to help, I have tried to ad a smooth transition to the slide show so that image change is not too brisk. But it seems that since I already have a -textpadding- for the images, I cannot ad a -transition ease- property in the CSS. One cancels the other. Should it be possible to use both simultaneously?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2025 Feb 09, 2025
quote

...since I already have a -textpadding- for the images, I cannot add a -transition ease- property in the CSS. One cancels the other.

By alpshiker

==========

Padding & Easing are wildly separate properties. 

 

The former provides empty space around an element like this:

image.pngexpand image

Easing specifies a transition's-timing-function — linear, slow to fast, fast to slow, etc... 

 

See CSS references below for details and code examples. 

https://www.w3schools.com/css/css_padding.asp

https://www.w3schools.com/cssref/css3_pr_transition-timing-function.php

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 09, 2025 Feb 09, 2025
LATEST

Thank you. I had a look, but I have to find out how this can be implemented with the script

https://stackoverflow.com/questions/46519126/how-to-randomize-the-slideshow-image-in-html

It is getting late here but I will dip into it ASAP.

Many thanks!

and thanks for putting my previous post straight.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

The align attribute is deprecated in HTML5, and styles should be used via CSS for better practices.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 09, 2025 Feb 09, 2025

Thank you again for your suggestions in helping me sort this layout problem I had with an image slide show. Since I am now asked by the forum community if my problem is solved, here is the short answer.

 

It was suggested that I start from new HTML5 page to see if this worked out better. Indeed, this solved the problem. In fact, after exploring the code, I realised that some of my pages lacked the introductory tag:

 

Capture d’écran 2025-02-09 à 18.20.14.pngexpand image

 

After adding the missing line, all my pages work now as they should, even if many elements are still outdated or marked as errors and should be renewed.

So yes, my problem is solved, and I thank you both wholeheartedly!

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines