Issues with the functionality of Bootstrap

Upon loading the page, I am encountering an issue with a collapse on the 'main' id. It fails to collapse initially and only functions correctly after being clicked. I have not utilized 'collapse in', so I am unsure why this behavior persists.

Additionally, when I click on the header, the container expands but then readjusts awkwardly. I would appreciate it if you could review the code provided to help me address these concerns.

Furthermore, my attempt at creating two columns in the header row seems to be failing. The divs are not aligning properly as the one with col-xs-2 is shifting to the bottom of the other column instead of appearing side by side. The same issue applies to the two buttons in the 'main' section. Your assistance in resolving these matters would be greatly appreciated.

<!DOCTYPE html>
<html>
<head>
<title>XYZ</title>
<link rel="stylesheet" href="custom-style.css">
<link rel="stylesheet" href="bootstrap.min.css">
<script src ="jquery-3.0.1.min.js"></script>
<script src ="bootstrap.bundle.min.js"></script>
</head>
<body>


         <div class="container" id="container">
                <div class="row" id="header">

                    <div class="col-xs-10" id="logo" data-toggle="collapse" data-target="#main">XYZ</div>

                    <div class="col-xs-2" id="arrow-down">Arrow</div>            

               </div>

               <div class="row" class="collapse" id="main">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-6" id="button1">
                                <button type="button" class="btn btn-primary active">Detail1</button>
                            </div>
                            <div class="col-xs-6" id="button2">
                                <button type="button" class="btn btn-primary disabled">Detail2</button>

                            </div>
                        </div>
               </div>

               </div>

        </div>


</body>
</html>

CSS styles:

*{
        margin: 0;
        padding: 0;
    }
#container{
    width:450px;
    border: 1px solid black;
    height: auto;

}

#header{
    background-color: #6C6D70;
    border-bottom: 5px solid #2DB5AB;
    height: 50px;
}

#logo{

    padding:10px;
    font-size: 18px;
    font-family: sans-serif;
    font-weight: bold;
    color: #FFFFFF;
}

#arrow-down{

    color:black;
    font-size: 18px;
    padding: 15px 10px 10px 10px;

    border: 1px;
}

#main{
    padding: 10px;
}

#video-detail{


}

#buttons{

    padding:10px;
    margin: 0 auto;
    border: 1px solid black;
}

Answer №1

Make sure to include the CSS class "collapse" on the #main element

<div class="row collapse" class="collapsed" id="main">

Check out the code on Jsfiddle: http://jsfiddle.net/yru9hf7t/

Answer №2

I believe this information will be beneficial

HTML Code Snippet

<div class="container" id="container">
    <div class="row" id="header">
        <div class="col-xs-10" id="logo" data-toggle="collapse" data-target="#main">ABC</div>
        <div class="col-xs-2" id="arrow-down">Arrow</div>
    </div>
    <div class="row collapse" class="collapsed" id="main">
        <div class="col-xs-12">
            <div class="row mystyle">
                <div class="col-xs-6" id="button1">
                    <button type="button" class="btn btn-primary active">Detail1</button>
                </div>
                <div class="col-xs-6" id="button2">
                    <button type="button" class="btn btn-primary disabled">Detail2</button>
                </div>
            </div>
        </div>
    </div>
</div>

CSS Styles

* {
    margin: 0;
    padding: 0;
}
#container {
    width:450px;
    border: 1px solid black;
    height: auto;
}
#header {
    background-color: #6C6D70;
    border-bottom: 5px solid #2DB5AB;
    height: 50px;
}
#logo {
    padding:10px;
    font-size: 18px;
    font-family: sans-serif;
    font-weight: bold;
    color: #FFFFFF;
}
#arrow-down {
    color:black;
    font-size: 18px;
    padding: 15px 10px 10px 10px;
    border: 1px;
}
.mystyle{
    padding:20px;
}
#buttons {
    padding:10px;
    margin: 0 auto;
    border: 1px solid black;
}

View working fiddle:http://jsfiddle.net/iamraviteja/ryqgm0ra/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Missing ghost image appears when you drag and drop the file

New to JavaScript... As a rookie in coding, I often get interesting requests from my partner who is a kindergarten teacher. Recently, she asked me to create a "Function Machine" for her classroom activities. With some trial and error, I managed to put tog ...

Unusual occurrence with the nth-child selector

For the fiddle, click here - http://jsfiddle.net/ashwyn/a45ha/ To see the HTML code, take a look below: <div class="parent"> <div class="a">Class A</div> <div class="b">Class B1</div> <div class="b">Class B ...

Prevent the crawling of HTML segments by utilizing HTML-XSL parsing techniques

I am currently working with Watson Explorer FC 11.0.2 and I am facing a challenge in excluding certain HTML tags from the Watson crawlers. I am using an XSLT parser to extract metadata, title, and body from an HTML page located at the following path: "/h ...

I seem to be having trouble with my dropdown menu, can anyone help me figure out what I might be doing wrong

I'm new to web development and I'm trying to create a dropdown menu. The issue is that when I hover over a specific element, it takes up more space than expected. My goal is for it to appear below the "shop" element. I'm not sure where I&a ...

enhance the brilliance of elements at different intervals

My latest CSS animation project involves creating a stunning 'shine' effect on elements with a specific class. The shine effect itself is flawless, but having all elements shine simultaneously is making it look somewhat artificial. I've bee ...

Personalized 404 Error Page on Repl.it

Is it possible to create a custom 404-not found page for a website built on Repl.it? I understand that typically you would access the .htaccess file if hosting it yourself, but what is the process when using Repl.it? How can I design my own 404-not found p ...

Adjust the position of a tkinter widget

I'm working with code that looks like this import tkinter as tk from tkinter import Tk from tkinter import ttk root = Tk() ttk.Label(root, text = 'label text', justify = 'center').grid(row=0, column=0) string = tk.StringVar() st ...

Adjustable TextBox (multiline input field)

In need of some assistance, I am working with a MultiLine asp:Textbox (similar to a standard html textarea) that I would like to have auto-sized to fit its content using only CSS. My goal is to have it display at a specified height in the web browser, with ...

Eliminate the gap between spans when wrapping words

I am facing a challenge with displaying text and an icon together in a div. The requirement is for the icon to always be positioned right next to the text, even when the text wraps due to limited space. Various solutions have been attempted, but they all ...

The anchor tag dwarfs the element it contains

I'm experiencing an issue on my website where the clickable area of my two images/buttons, labeled Get Started and Learn More, is larger than the actual image itself. I've wrapped the images with anchor tags to link to separate pages, but for som ...

Exploring ways to programmatically click on a button located beneath a text using the Selenium library in Python

I am interested in creating a bot that can automatically like comments on a web page. Each comment has a like and dislike button attached to it. The xPath for the comment is: //*[@id="commentText-40538697"]/span The xPath for the like button is: //*[@id ...

Browser disregards backslashes in the content of pseudo elements

I have been struggling with a simple issue for quite some time now, and I seem to be out of ideas. The problem lies in the styling of a CSS pseudo-element before, which is defined as follows: #fPhone::before{ color: #78be20; content: "\e622" ...

What is the process for creating a sub-menu for a dropdown menu item in Bootstrap 5?

https://i.sstatic.net/o4FLn.pngthis is my code which i have created this navigation bar with bootstrap and all of its drop downs but i want to add another drop down to the services drop down section inside of webdevelopment but it can't any easy solut ...

Unable to create adjacent buttons using display:inline-block

I'm using Angular to dynamically create buttons, but they are stacking vertically instead of appearing side by side <div *ngIf="response"> <div *ngFor="let hit of response.hits.hits"> <button class="btn btn-primary" role="butt ...

Fixing the issue: "Tricky situation with JavaScript not working within Bootstrap 4's div tag while JS functions properly elsewhere"

Currently, I'm working on implementing a hide/show function for comments using JavaScript. Fortunately, I was able to find a helpful solution here (thanks to "PiggyPlex" for providing the solution on How can I hide/show a div when a button is clicked? ...

The 'Required' attribute in HTML is malfunctioning

The 'required' attribute is not functioning properly when I try to submit the form. I've searched online for a solution, but none of them have resolved my problem. Take a look at the code snippet below - I've used the required attribute ...

Nested tables in CSS

Creating a Gridview with two nested Gridviews in separate cells may result in some CSS inheritance issues. Each row of the table contains these nested Gridviews, but trying to isolate their style using CssClass doesn't always work effectively. Is the ...

Need help positioning this HTML iframe on my webpage?

Can anyone help me figure out how to position this HTML i-frame in a specific place on my webpage? <div style="overflow: hidden; width: 333px; height: 156px; position src="h: relative;" id="i_div"><iframe name="i_frame"http://url.com/click.php?a ...

hiding an "input type="file" element by using a button to conceal it

Is it possible to create a button that triggers file upload functionality? I couldn't find any solutions on Google. I've heard it can be done with labels, but I specifically need to use a button for better UX/UI. <button style="position:fixe ...

What is the reason for Bootstrap requiring both a class name and an ID name for collapse functionality?

When implementing the collapse effect in Bootstrap, why do buttons need to refer to the data-toggle=collapse class and the data-target=#collapseExample ID of the panel for the effect? Wouldn't simply targeting the ID be enough to toggle its state? Co ...