I can't see the background color in my DIV element. What could be causing this issue?

/**This code is not changing the color of the row1 class**/

html, body {
  font-family :'montserrat',sans-serif;
  }
h1 {
  border-left  : 2px solid #00f28f;
  font-size    : 48px;
  font-weight  : 400;
  padding-left : 20px;
  }
.main {
  margin-top : 80px;
  }
form input {
  background : #F0f0f0;
  border     : none;
  font-size  : 36px;
  padding    : 20px;
  width      : 100%;
  transition : background 0s, border-left 0s;
  }
form input:focus {
  background  : #fff;
  border-left : 2pxsolid #000;
  box-shadow  : none;
  outline     : none;
  }
button.button {
  background : transparent;
  border     : none;
  color      : #00f2bf;
  cursor     : pointer;
  font-size  : 36px;
  padding    : 20px 24px;
  transition : background 0s, border-left 0s;
  }
button.button:hover {
  background : #00f2bf;
  color      :  #fff;
  }
.row1 {
  background : yellowgreen;
  }
<link href="https://fonts.google.com/specimen/Poppins?preview.size=20" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="C:\Users\kalyanasundar.s\OneDrive - HCL Technologies Ltd\Desktop\proj\proj.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>


<header class="header">
  <div class="container">
    <div class="row">
      <div class="col-xs-2 col-md-2">
        <h1>Kalyan The Coder</h1>
      </div>
    </div>
  </div>
</header>
<div class="main">
  <div class="container2">
    <div class="row1">
      <form class="form">
        <div class="col-xs-8 col-md-4">
          <input type="text" id="TextBox1" placeholder="Enter your query">
        </div>
        <div class="col-xs-4 col-md-2">
          <button type="submit" class="button">post</button>
        </div>

The code seems to be functioning correctly except for the fact that the color of row1 does not change as expected.
Switching row1 to row in the CSS results in a change to the header color, which is not what was intended.
As a beginner, I am eager to delve deeper into this topic.

Answer №1

One important thing to note is that you must specify the height of your element.


This simple adjustment can help solve the problem at hand. By adding height: 100px to your row1 class, the background color will change to the desired yellowgreen:

.row1 {
    background: yellowgreen;
    height: 100px;
}

To further illustrate this point, let's compare two snippets:

.row-1 { background-color: yellowgreen; }
.row-2 {
  height: 100px;
  background-color: red;
}
<div class="row-1"></div>
<div class="row-2"></div>

As shown above, without a specified height like in row-1, the element might not be visible. Adding height or padding will make it visible:

.row-1 { background-color: yellowgreen; }
<div class="row-1">
  <p>This should make the row visible.</p>
</div>

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

Displaying items using the flex property can cause the top resize feature to be unreachable

My issue revolves around the display of input errors, which are causing the top section to become inaccessible. I am looking for a solution that will align the content both vertically and horizontally in the center. The challenge arises when the card conta ...

At what point are DOMs erased from memory?

Recently, I've been working on an application that involves continuous creation and removal of DOM elements. One thing I noticed is that the process memory for the browser tab keeps increasing even though the javascript heap memory remains steady. To ...

The Lighthouse tool consistently indicates a high Cumulative Layout Shift (CLS) score, even after adjusting

On the Lighthouse report, Cumulative Layout Shift shows a high number: 0.546 Upon analyzing the trace, I noticed that the image block initially does not take up the required space and pushes down the content below. Refer to the image: https://i.sstatic.ne ...

What is causing the table to not be displayed in this Javascript program when it is used in a

I am currently experimenting with incorporating an infinite loop before the prodNum and quantity prompts to consistently accept user input and display the output in a table. Although the program is functional when executed, it fails to showcase the table ...

Utilizing the CSS Top and Left attributes along with Jquery animations

There are two divisions on a page, namely Left_Div and Right_Div. The images in the Right_Div are positioned using CSS properties such as Top and Left. The Left_Div acts as a left panel, and upon clicking a button, both Left_Div and Right_Div animate to sl ...

A problem arises when trying to showcase the content in a responsive manner on the hamburger menu, particularly when viewing on mobile

As a newcomer to web development, I decided to challenge myself by building an E-Commerce website to enhance my skills. To ensure mobile responsiveness, I opted for a hamburger menu to hide the navbar content. However, despite resizing working flawlessly, ...

Creating a unique and personalized dual-row navigation bar using Bootstrap

Currently, I am striving to achieve a "conflict free" two-row fixed-top navbar in Bootstrap 3. I am unsure if it necessitates two separate "navbars" according to the official Bootstrap definition. While I possess decent coding skills, my knowledge of the B ...

Tips on extracting information from a list of website links

I have been working on a project to extract information from various websites and store it in a JSON file. The desired output format is as follows : [ { "title": "Python developer", "place": "Slovensko ...

What is the best way to eliminate the border in IE edge that surrounds special characters?

Here is the current appearance of the cross button in IE/Edge: https://i.sstatic.net/JZ37V.png And here is how it is supposed to look: https://i.sstatic.net/Uqafg.png Upon inspecting the CSS, it reveals that the #10006 html character has a color code o ...

Explain the concept of paragraph spacing in Word, including how it is

When working with my ms word 2010 document, I often use the includetext-function to incorporate HTML content: { INCLUDETEXT "test.html" } Here is an example of the HTML code that I am trying to include: <html> <head> <meta http-equiv="Co ...

Creating responsive modal windows in Vue and Laravel to dynamically adjust to the screen size

I am currently working with a modal window code snippet. <transition name="modal" @close="showModal = false"> <div class="modal-mask" style=" width: 90% !important;"> <div class="modal-wrapper"> < ...

Currently in the process of refreshing a Drupal website with only access to a HostGator login

I've taken on a last-minute favor for a friend who needs a quick Valentine's Ad added to their existing website, which was built with Drupal in 2010 by someone they no longer have contact with. I don't have much experience with Drupal, but I ...

Conditionally change CSS class for a table based on a certain condition

I am facing an issue with styling a table that has the following class applied: <table class="table table-striped table-borderless nowrap"> Specifically, I want to change the background color of certain rows based on user conditions like this: < ...

The sub-navigation element goes beyond the traditional navigation bar and causes misalignment

I'm currently in the process of developing sub navigation bars that expand upon hover. However, I've encountered an issue where hovering over "Manage" triggers the regular box to expand. This is happening because of the position: relative within ...

The combination of list-style-type and display:inline is ineffective

Many questions have been asked in different areas about this issue, but none of the answers I found were able to solve my problem. My challenge lies in creating a navigation menu where I can't remove the list style or display it inline. Here is the HT ...

Is the presence of a <ul> required within the <nav> element?

I was reading an article on which highlights the importance of using the <nav> tag for semantic purposes. Throughout the examples provided, the article consistently utilizes the <ul> tag and emphasizes its usage. Now I'm curious, is thi ...

Building a dynamic hierarchical list in Angular 8 with recursive expansion and collapse functionality

I am attempting to construct a hierarchical expand/collapse list that illustrates a parent-child relationship. Initially, the parent nodes will be displayed. If they have children, a carat icon is shown; otherwise, a bullet icon appears. When the carat ico ...

Error: The argument passed to int() must be a string, bytes-like object, or number, not 'NoneType' (Issue when sending HTML input to Python)

#!C:\Users\aan\AppData\Local\Programs\Python\Python39\python.exe import numpy as np import skfuzzy as fuzz import cgi from skfuzzy import control as ctrl print("Content-type:text/html\r\n\r\n ...

Tips for refreshing a page upon submission

My Bootstrap Modal contains a form with Submit and Cancel buttons. The cancel button is working correctly and closes the Modal successfully. However, when I click on the Submit Button, the form submits successfully to the Web Service but the Modal does not ...

Automatic capitalization of menu options in Bootstrap dropdown

Is anyone else curious about why the menu items are in all caps while the markup is in lower case? What steps can be taken to prevent this from happening? https://i.stack.imgur.com/S86RO.png ...