Child element's CSS is failing to apply, while the parent element's styling is functioning correctly

I have developed a small quiz application where, after answering questions, I display a progress bar. The issue I am facing is with the styling of the progress bar. I have set up two div elements for this purpose - one as the parent element (id = "progressBar") and the other as the child element (id= "progressBarFull"). While applying CSS to the parent div works fine, the CSS applied to the child div is not taking effect. Can someone help me understand why?

.choice-container{
    display: flex;
    margin-bottom: 0.5rem;
    width: 90%;
    font-size: 1.8rem;
    border: 0.1rem solid rgb(86, 165, 235,0.25);
    background-color: white;

}

.choice-prefix{
    background-color: #56a5eb;
    padding: 1.5rem 2.5rem;
    color: white;

}

.choice-text{
    padding: 1.5rem;
    width: 100%;
}

.choice-container:hover{
    cursor:pointer;
    box-shadow: 0.4rem 0.6rem rgba(86, 185, 235, 0.5);
    transform: translate(-0.1rem);
    transition: transform 150ms;
}

.correct{
    background-color: #28a745;
}

.incorrect{
    background-color: #dc3545;
}
/* HUD DISPLAY */

#hud{
    display: flex;
    justify-content: space-between;
}

.hud-prefix{
    text-align: center;
    font-size: 2rem;
}

.hud-main-text{
    text-align: center;
}

#progressBar{
    width : 20rem;
    height: 3.1rem;
    border: 0.3rem solid #56a5eb;
};

#progressBarFull{
    height: 2.5rem;
    background-color: #56a5eb;
   
};
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quick Quiz - Play</title>
    <link rel="stylesheet"  href="app.css" />
    <link rel="stylesheet"  href="game.css" />
</head>
<body>
    <div class="container">
        <div id="game" class="justify-center flex-column">
            <div id="hud">
                <div class="hud-item">
                    <p id= "progressText"class="hud-prefix">
                        
                    </p>
                   <div id="progressBar">
                       <div id="progressBarFull"></div>
                   </div>
                </div>
                <div class="hud-item">
                    <p class="hud-prefix">
                        Score
                    </p>
                    <h1 class="hud-main-text" id="score">
                        
                    </h1>
                </div>
            </div>
            <h2 id="question">What is the answer to this question?</h2>
            <div class="choice-container">
                <p class="choice-prefix">A</p>
                <p class="choice-text" data-number="1">Choice 1</p>
            </div>
            <div class="choice-container">
                <p class="choice-prefix">B</p>
                <p class="choice-text" data-number="2">Choice 2</p>
            </div>
            <div class="choice-container">
                <p class="choice-prefix">C</p>
                <p class="choice-text" data-number="3">Choice 3</p>
            </div>
            <div class="choice-container">
                <p class="choice-prefix">D</p>
                <p class="choice-text" data-number="4">Choice 4</p>
            </div>
        </div>
    </div>
    <script src="game.js"></script>
</body>
</html>

Click here for the output

Answer №1

To fix the issue, simply remove the semicolons after each closing brace:

#progressBar{
    width : 20rem;
    height: 3.1rem;
    border: 0.3rem solid #56a5eb;
} /* remove semicolon here */

#progressBarFull{
    height: 2.5rem;
    background-color: #56a5eb;
   
} /* remove semicolon here */

It's important to follow proper CSS syntax guidelines as adding unnecessary semicolons can disrupt the parsing process by user agents. For more information, you can refer to the MDN article on CSS syntax.

Answer №2

Make sure to correct the semicolon placement after progress Bar, and it's recommended to set the height as a percentage.

.choice-container{
    display: flex;
    margin-bottom: 0.5rem;
    width: 90%;
    font-size: 1.8rem;
    border: 0.1rem solid rgb(86, 165, 235,0.25);
    background-color: white;

}

.choice-prefix{
    background-color: #56a5eb;
    padding: 1.5rem 2.5rem;
    color: white;

}

.choice-text{
    padding: 1.5rem;
    width: 100%;
}

.choice-container:hover{
    cursor:pointer;
    box-shadow: 0.4rem 0.6rem rgba(86, 185, 235, 0.5);
    transform: translate(-0.1rem);
    transition: transform 150ms;
}

.correct{
    background-color: #28a745;
}

.incorrect{
    background-color: #dc3545;
}
/* HUD DISPLAY */

#hud{
    display: flex;
    justify-content: space-between;
}

.hud-prefix{
    text-align: center;
    font-size: 2rem;
}

.hud-main-text{
    text-align: center;
}

#progressBar{
    width : 20rem;
    height: 3.1rem;
    border: 0.3rem solid #56a5eb;
}

#progressBarFull{
    height: 100%;
    background-color: #56a5eb;
   
};
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quick Quiz - Play</title>
    <link rel="stylesheet" href="app.css" />
    <link rel="stylesheet" href="game.css" />
</head>
<body>
    <div class="container">
        <div id="game" class="justify-center flex-column">
            <div id="hud">
                <div class="hud-item">
                    <p id= "progressText"class="hud-prefix">
                        
                    </p>
                   <div id="progressBar">
                       <div id="progressBarFull"></div>
                   </div>
                </div>
                <div class="hud-item">
                    <p class="hud-prefix">
                        Score
                    </p>
                    <h1 class="hud-main-text" id="score">
                        
                    </h1>
                </div>
            </div>
            <h2 id="question">What is the answer to this question?</h2>
            <div class="choice-container">
                <p class="choice-prefix">A</p>
                <p class="choice-text" data-number="1">Choice 1</p>
            </div>
            <div class="choice-container">
                <p class="choice-prefix">B</p>
                <p class="choice-text" data-number="2">Choice 2</p>
            </div>
            <div class="choice-container">
                <p class="choice-prefix">C</p>
                <p class="choice-text" data-number="3">Choice 3</p>
            </div>
            <div class="choice-container">
                <p class="choice-prefix">D</p>
                <p class="choice-text" data-number="4">Choice 4</p>
            </div>
        </div>
    </div>
    <script src="game.js"></script>
</body>
</html>

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

Managing the height of a hero section with TailwindCSS and React.js

Embarking on my first website project using React and Tailwind has been an exciting learning experience. My vision is to showcase a Hero Section prominently at the top, with a Nav bar situated elegantly at the bottom of the screen. To bring this concept ...

Is there a way to convert various elements sharing the same class into a list of array items?

Essentially, I am dealing with multiple elements sharing the same class name. My goal is to retrieve an array of integers from an API and then iterate through each element with this class name, replacing them with elements from the array sequentially. For ...

Guide on customizing webpack to incorporate SCSS in a React application

After creating my React app using create-react-app (with React ver. 16.6.3), I decided to incorporate SCSS into my components. To begin, I ran the eject script and made necessary adjustments in webpack.config.dev.js: { test: cssRegex, exclude: cssMo ...

Conceal the second click action within the anchor tag

Is there a way to hide the second click event on all anchor tags except those that trigger popupfun? I have a sample page set up. [Check out the JS Fiddle here][1] http://jsfiddle.net/ananth3087/LgLnpvf4/15/ Link Anchor Tags: The page includes two ...

The checkbox label should be centered directly beneath the checkbox

I'm feeling a bit lost. I came across this code snippet on jsfiddle: https://jsfiddle.net/rx90f38u/1/ There seems to be some styling included, but I can't figure out why the "remember" me text is showing below the checkbox. The checkbox and it ...

Endless looping of numerous consecutive animations

Is it possible to apply two animations to an element using only CSS and without the need for JavaScript? These animations should run sequentially an infinite number of times. @keyframes show { from, to { z-index: 100; } } @keyframes wait { ...

What is the best way to eliminate tags from a BeautifulSoup-scraped list?

When using beautifulsoup to scrape a page, I am trying to extract the "title" by searching for specific tags: title = [text.find_all('h1', {'class', 'entry-title'}) for text in texts] The resulting output is a list like this: ...

The menu seems to be off-center

I'm struggling to center my menu/navigation bar horizontally. I can't seem to figure out what mistake I've made or what I've forgotten. Additionally, there is right padding after my last list item. How can I get rid of it? HTML <di ...

The Cascading of Bootstrap Card Designs

Looking for some assistance with my TV Show Searcher project that is based on an API. The functionality is complete, but I'm struggling to get the Bootstrap cards to stack neatly without any empty space between them. I want it to resemble the image ga ...

Embed a video onto a webpage using HTML and ensure it is responsive by implementing Bootstrap's grid

I am currently using the mPurpose-master bootstrap theme, which offers a feature allowing the placement of 3 blocks in a row that are fully responsive. <div class="section"> <div class="container"> <div class="row"> ...

Hidden Bootstrap 4 Layout: Utilizing 2 Columns

For my latest project, I'm designing a bootstrap webpage with a 4-column grid layout. The twist is that two of these columns will initially be hidden - one on the left and the other on the right. By clicking a toggle button on the left, the user can r ...

What is preventing my Button's onClick() method from being effective?

Below is a snippet of my HTML layout using the sciter framework: <div id="volume_micphone_slider" style="z-index:1;"> <input id="volume_slider" class="volume_slider" type="vslider" name="p1c" max="100" value="20" buddy="p1c-buddy" /> < ...

Is it possible for me to utilize code blocks within the head content and link tags to make reference to specific themes

I am currently in the process of developing an ASP.NET application using themes. I have successfully assigned a theme to the application via the web config file. One issue I am facing is trying to reference a bookmark icon located within the themes direct ...

Voting mechanism - clicking to activate class and subsequently removing it

Looking to implement a feature where users can vote by clicking an up or down arrow. While the Ajax calls are straightforward, I'm facing some challenges on the visual aspect. Here is my HTML setup: <td class="td5"> <a class="vote" href=" ...

A variety of products combined into a single form

I am looking to enhance my form by allowing users to add multiple entries before submitting, similar to an "add to cart" feature. The added entries should be displayed on the same page in a separate div along with a submit button. Once the user is ready, t ...

Font size transition on pseudo elements is not functioning properly in Internet Explorer when using the "em" unit

When I hover over, the font awesome icon and text on this transition increase in size. All browsers work well with this effect except for IE 11. This example demonstrates the same transition using px (class test1) and em (class test2). While using px wor ...

The concealment of the container is ineffective when attempting to hide it until all cached images are

My website has a background and a main container. I wanted to hide the container until the entire page had loaded, so I included #cover{opacity:0} at the beginning of the page and $(window).load(function() { $('#cover').css('opacity&apo ...

Utilizing Angular 2+ with the [innerHTML] property to incorporate HTML with added style attributes

I am currently utilizing Angular 2+ [innerHTML] input for inserting HTML formatting that includes style tags. Within my template, the code looks like this: <span [innerHTML]="someVar"></span> In the component file, I have defined: someVar = ...

Creating dependent dropdown lists is a useful way to streamline data entry and ensure accuracy in your

I am looking to create a series of 4 connected dropdown lists, structured like this: District: <select id="district"> <option>Select a District</option> <option value="district1">dstrict1</optio ...

Step-by-step guide on programmatically activating a radio button

I am working with a radio button and input field. I need the ability to programmatically toggle the radio button so that when this.iAreaOfCoverageForThresholdPasser.average-height is set to true, the radio button appears highlighted. Snippet of HTML: < ...