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

Collapse a headline?

New Here ,
May 23, 2025 May 23, 2025

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.

TOPICS
How to
2.4K
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
New Here ,
May 23, 2025 May 23, 2025

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.

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
New Here ,
May 23, 2025 May 23, 2025

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.

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 ,
May 23, 2025 May 23, 2025

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.

 

 

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
Community Expert ,
May 23, 2025 May 23, 2025

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%;
}

 

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
New Here ,
May 24, 2025 May 24, 2025

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.

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 ,
May 24, 2025 May 24, 2025

Use your browser's Inspect Feature.

Right-click ⇒ Inspect (F12 function key).

 

See screenshot from https://www.bassett.net/pages/david2.shtml

image.png

 

 

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
New Here ,
May 25, 2025 May 25, 2025

 

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.

KathrynPasadenaCA_0-1748169195990.png

If I change using the inspector, I'm getting more what I expected.

KathrynPasadenaCA_1-1748169381435.png

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.

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
New Here ,
May 25, 2025 May 25, 2025

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.

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 ,
May 24, 2025 May 24, 2025

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.

image.png

 

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
New Here ,
May 25, 2025 May 25, 2025

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.

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 ,
May 25, 2025 May 25, 2025

#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.

image.png

 

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
New Here ,
May 25, 2025 May 25, 2025

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.

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 ,
May 26, 2025 May 26, 2025
quote

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.

 

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
New Here ,
Jun 04, 2025 Jun 04, 2025

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?

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 ,
Jun 04, 2025 Jun 04, 2025

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:

BenPleysier_0-1749098650867.png

 

Try it for yourself, you'll be surprised!

 

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
New Here ,
Jun 05, 2025 Jun 05, 2025

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.

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
New Here ,
Jun 05, 2025 Jun 05, 2025
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 ,
Jun 05, 2025 Jun 05, 2025
<!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>
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
New Here ,
Jun 05, 2025 Jun 05, 2025

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.

 

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 ,
Jun 05, 2025 Jun 05, 2025

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

 

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
New Here ,
Jun 05, 2025 Jun 05, 2025

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?

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
LEGEND ,
Jun 05, 2025 Jun 05, 2025
quote

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!

 

 
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 ,
Jun 05, 2025 Jun 05, 2025

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.

 

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
LEGEND ,
Jun 05, 2025 Jun 05, 2025

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!!!!

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