Copy link to clipboard
Copied
I have this page I'm working on: https://www.bassett.net/pages/david.shtml - yes I know I need to redo my website to make it responsive, but no time at preset. What I want to do, is to have the items under each headline be collapsd unless they click on a plus or arrow to open the content.
Example of what I have in mind: https://liquiddeath.com/pages/faq
I tried following along https://www.youtube.com/watch?v=Zgqbbg3EW7Q, that uses https://www.w3schools.com/howto/howto_js_accordion.asp, but had issues on exactly where the segments of code would go, in relation to the code already there.
Is it even possible when using a page with shtml? I have a vague memory from year ago that there was a way to have my interior part of the page pull in an htm, but I'm not sure if it's my imagination or not. I WAS able to make an htm/html that worked from the YouTube.
I'm using Dreamweaver 21.4 and Windows 10.
Copy link to clipboard
Copied
Hmm, I figured out the include, I knew I'd used it before - it's in the sidebar. So, since posting original post, I've now included https://www.bassett.net/pages/AccordianSample.html
When pulling that page up in browser, the content uses the whole width. But when including it in https://www.bassett.net/pages/david2.shtml, it only uses about 25% of the available width. Why is that?
While waiting for an answer, I'll experiment on adding an image like a plus sign.
Copy link to clipboard
Copied
I'm satified now with https://www.bassett.net/pages/AccordianSample.html
So the remaining question is why isn't https://www.bassett.net/pages/david2.shtml full width of the white area? Hopefully, I figure it out while waiting for a response, but... just in case.
Copy link to clipboard
Copied
Your Accordion Panel is 100% width.
.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 20px;
transition: 0.4s;
}
When Accordions are placed inside other containers, they are constrained to the maximum width of the parent element, whatever that may be -- 25%, 50% or 75% of screen width.
Copy link to clipboard
Copied
You placed your Accordion panel inside a floated <div> that's only 500px wide. Remove the float and width.
#left {float: left;width: 500px;
margin-left: 50px;
margin-right: 0%;
}
Copy link to clipboard
Copied
Nancy, thanks for your willingness to help. I must have made some changes since you looked, as I can't find the div you mention, in either AccordianSample or in David2. Please tell me which file needs correcting and what to search on to find the change(s)? I searched on 500 without success in either. I'm not touching either file until you answer, so I don't mess up further.
Copy link to clipboard
Copied
Use your browser's Inspect Feature.
Right-click ⇒ Inspect (F12 function key).
See screenshot from https://www.bassett.net/pages/david2.shtml
Copy link to clipboard
Copied
First thanks is for the F12 tip. I knew something like that existed, but I couldn't find it for the life of me. I've put that tip into my Dreamweaver notes AND my Firefox note, so that next time, I'll find it.
Next, now that I'm using the inspector, I see that I was looking at the html and shtml files and forgot to look in the css file (great that it even tells you the line number)
However, although I now have
#left {
margin-left: 2px;
margin-right: 0%;
and have uploaded it, the inspector still is showing the old figures.
If I change using the inspector, I'm getting more what I expected.
So, why does it work via the inspector? That doesn't save the underlying css file, right? That's just an "on the fly" trial? I will work on the excess codes while I await your reply of what I did wrong this time., and why it's not reading the updated css.
Copy link to clipboard
Copied
Aha, getting somewhere! Not exactly with the code errors, but I figured out that #left was being used in the left side menu. So I made a new div called #collapse and referred to that instead. Now my only issue for the time being is the right marging of the content of the accordions. I've tried margin-right: -2px; and margin-right: 2px; and the content still "hangs over" into the right side menu area. Expend Cause of Death and you'll see what I mean. Do I need a wrapper of some sort, or what?
Time to try to get back to sleep, now that I've made some progress.
Copy link to clipboard
Copied
Also fix your code errors. Your page contains duplicate tags before and after the <body>. Only one set of tags are allowed. Remove excess code from your server-side include files.
https://validator.w3.org/check?verbose=1&uri=https%3A%2F%2Fwww.bassett.net%2Fpages%2Fdavid2.shtml
Basic HTML page.
Copy link to clipboard
Copied
Hmm, I'll have to put off the code errors until after I get the content of his memorial all finished. It looks to be more than I have the time for at the moment. They will be moot when I redesign with a more up to date method anyway.
Copy link to clipboard
Copied
#collapse {
width: 95%;
border: 1px solid red /**THIS IS FOR DEMO PURPOSES ONLY**/
}
.panel {padding: 0 18px; /**OMIT**/width: 100%; /**OMIT**/display: none; /**OMIT**/
background-color: white;overflow: hidden; /**OMIT**/
font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
font-size: 20px;
}
Screenshot with these changes.
Copy link to clipboard
Copied
I didn't get the red border but since it was for demo purpose, not important, Two more questions and I'll quit for the time being.
I didn't do anything to the left menu and using the inspector, I can't figure out what is different between https://www.bassett.net/pages/david2.shtml and https://bassett.net/pages/qr.shtml with regard to the positioning of the left menu. Can you see it?
Can you steer me to some tips on how to be sure each section is closed when opening the page? Or, better yet, if one opens A, all the others will close; same with the other sections? If it can't be done without JavaScript or something else, it's not a deal breaker. But starting with all sections closed is preferred.
Copy link to clipboard
Copied
I didn't get the red border...
By @Kathryn - Pasadena CA
===========
The screenshot image should be self-evident. The red border shows an outline around your #collapse Div so you can see what you're working with.
The other problems can't be addressed until you first resolve the code errors.
Window ⇒ Results ⇒ Validation... Check Document & fix reported errors.
My advice is to remove negative margins from your CSS. They create far more problems than they fix.
Have a pleasant Memorial Day of Remembrance.
Copy link to clipboard
Copied
Hi Nancy, I hope you can help me with one more thing. I made a workaround for the left side menu, until I have a chance to rework the entire site (I promise I will do that, as I want to make it responsive anyway).
https://bassett.net/pages/David.shtml - How do I make all the accordions open in the "closed" position instead of the open position?
Copy link to clipboard
Copied
May I suggest an alternative approach?
Copy and paste the following code into a new document and view it in your favourite browser:
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>David Bassett 1945-2025</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="http://bassett.net">Home - Bassett.net</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<!-- Main Container -->
<div class="container mt-4">
<div class="row">
<!-- Sidebar -->
<div class="col-md-3">
<div class="card">
<img src="/photos/family/2025-05-02-justDave.jpg" class="card-img-top img-fluid" alt="David Bassett">
<div class="card-body text-center">
<h5 class="card-title">Kathryn & Dave</h5>
<p>2008 Trip to Alaska</p>
</div>
</div>
</div>
<!-- Content Section -->
<div class="col-md-9">
<h1>David Bassett 2 May 1945 - 16 May 2025</h1>
<!-- Accordion Section -->
<div class="accordion" id="biographyAccordion">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#birthYears">
Birth and Elementary Years
</button>
</h2>
<div id="birthYears" class="accordion-collapse collapse" data-bs-parent="#biographyAccordion">
<div class="accordion-body">
<p>Born to Charles Harold Bassett and Sarah Gertrude Jones.</p>
<p>Coming soon: Various pictures including the Model T he learned to drive on.</p>
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#highSchool">
High School and Vietnam
</button>
</h2>
<div id="highSchool" class="accordion-collapse collapse" data-bs-parent="#biographyAccordion">
<div class="accordion-body">
<p>Stories from his time in the service, including Vietnam, Bob Hope’s visit, and more.</p>
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#workingYears">
Working Years
</button>
</h2>
<div id="workingYears" class="accordion-collapse collapse" data-bs-parent="#biographyAccordion">
<div class="accordion-body">
<p>Details about his teaching career, construction experience, and locksmith work.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
How did I get this code? I opened your current page in my Edge browser. Then I opened Copilot (top right corner of the browser) and asked to "give me the HTML code for the whole document using Bootstrap 5.3"
This was the reply:
Here's a modernized version of your document using Bootstrap 5.3 for improved responsiveness, accessibility, and styling. It replaces custom JavaScript accordions, outdated inline styles, and manual layout structures with Bootstrap components.
Key Improvements:
- Bootstrap grid system (`container`, `row`, `col-*`) for proper responsiveness.
- ccordion component for collapsible sections.
- Navbar for intuitive site navigation.
- Bootstrap card components for structured content.
- Image responsiveness (`img-fluid`) for better display on all devices.
---
Updated HTML Code Using Bootstrap 5.3
(as shown above)
Additional Enhancements
Fully responsive layout using Bootstrap grid.
Improved readability with better font sizing and spacing.
Bootstrap components replace custom styles and scripts.
Accordion system for structured content browsing.
Would you like additional features, such as a footer or contact form? 😊
The result:
Try it for yourself, you'll be surprised!
Copy link to clipboard
Copied
Looks like something I'll look into when I rebuild whole website, but no time to do that until after funeral. My apologies for not giving the right url for the more pressing need.
https://www.bassett.net/pages/AccordianSample.html
This is the included page which I want to open in collapsed mode instead of expanded. I understand most of html (with the help of Dreamweaver), but Javascript is brand new to me.
Hmm, after I post this, I'll try your bootstrap trick with just that page and see what happens. Thanks for suggesting a way forward for when I revamp whole site. It looks intriguing.
Copy link to clipboard
Copied
Another wrong url. It's https://www.bassett.net/pages/DavidAccordion.html
Copy link to clipboard
Copied
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>David Bassett Memorial</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="https://www.bassett.net">Bassett.net Home</a>
</div>
</nav>
<!-- Main Container -->
<div class="container mt-4">
<h1 class="text-center">David Bassett Memorial</h1>
<!-- Accordion Section -->
<div class="accordion" id="memorialAccordion">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#birthYears">
Birth and Early Years
</button>
</h2>
<div id="birthYears" class="accordion-collapse collapse" data-bs-parent="#memorialAccordion">
<div class="accordion-body">
<p>Born to Charles Harold Bassett and Sarah Gertrude Jones.</p>
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#highSchool">
High School and Military Years
</button>
</h2>
<div id="highSchool" class="accordion-collapse collapse" data-bs-parent="#memorialAccordion">
<div class="accordion-body">
<p>Stories from his service in Vietnam, including Bob Hope’s visit.</p>
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#career">
Career and Contributions
</button>
</h2>
<div id="career" class="accordion-collapse collapse" data-bs-parent="#memorialAccordion">
<div class="accordion-body">
<p>His years as a teacher, locksmith, and construction worker.</p>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Copy link to clipboard
Copied
Getting there. https://www.bassett.net/pages/bootstrap.html
I did some copy/paste of the code to get all of the sections. Did something wrong in the process, as the first section expands correctly, But the rest of them - if you open one, they all open; not just the single section.
I'm bleary eyed from lack of sleep, so need to stop. I have to get up in an hour; hopefully, since I've made progress, I can sleep for a bit.
Copy link to clipboard
Copied
The problem lies with the ID of each of the accordion panels. Each of the conecutive ID are #highSchool
Each panel should have a unique ID. You will find highSchool in several places for each panel
Copy link to clipboard
Copied
Got it! Lack of sleep struck again making me not see the obvious pattern.
https://www.bassett.net/pages/bootstrap.html Now the only thing left (for this page anyway), is what am I doing wrong with the H1 and image. I have <h1 align="center"> and <img align="center". The heading centers, but the image does not, so what's wrong there? Did I misplace the center part of the code?
Copy link to clipboard
Copied
Got it! Lack of sleep struck again making me not see the obvious pattern.
https://www.bassett.net/pages/bootstrap.html Now the only thing left (for this page anyway), is what am I doing wrong with the H1 and image. I have <h1 align="center"> and <img align="center". The heading centers, but the image does not, so what's wrong there? Did I misplace the center part of the code?
By @Kathryn - Pasadena CA
As you are using Bootstrap in the example use some dedicated Bootstrap css classes (see in red below):
<h1 class="text-center">David Bassett<br>2 May 1945 - 16 May 2025</h1>
<img class="mx-auto d-block" src="/photos/family/2025-05-02-justDave.jpg width="555" alt="David Bassett">
That should do it!
Copy link to clipboard
Copied
This is invalid HTML5 code. It's been deprecated for many years. DO NOT USE.
align="center"
Instead, use the built-in Bootstrap utility classes. The CSS is already built for you.
https://getbootstrap.com/docs/5.3/utilities/text/
https://getbootstrap.com/docs/5.2/layout/columns/
It's important to respect the Bootstrap container, row, column structure. Without it, you won't get reliable results.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap 5.3 Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container mt-4">
<div class="row">
<div class="col mx-auto text-center">
<h1>David Bassett<br>2 May 1945 - 16 May 2025</h1>
<img src="/photos/family/2025-05-02-justDave.jpg" width="555" alt="David Bassett">
<!--col end--></div>
<!--row end--></div>
<!--new row-->
<div class="row">
<div class="col">
<!--Accordion Panel here-->
<!--col end--></div>
<!--row end--></div>
<!--container end--></div>
</body>
Hope that helps.
Copy link to clipboard
Copied
The arrow icons in the panels are a bit confusing.....they should be pointing down as the default position signifying there is some information beneath the panel title to view and then up when the panel is open, signifying it can be closed......surely that's the way!!!!
Personally I'm not sure even when using Bootstrap you need to adhere strictly to the col/row suggestion to house content when the information is so basic....in this case I don't see it causing any issues and its lighter in terms of code bloat, which we all know Bootstrap is renowned for!!!
I would not advise using a Bootstrap accordion in a predominately non-bootstrap website if that is the idea as you'll only be leveraging about 3% of the javascript, leaving 97% bloat...........gulp!!!!......not to mention the 1000's of lines of redundant css!!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now