Trouble with ASP.NET Master Page CSS Rendering Incorrectly

My CSS seems to be causing some trouble as the DIVs are not aligning as they should. Instead, they are just wrapping around the text and not adjusting the page layout properly. Here is an example of my CSS:


body {
    height: 95%;
    width: 100%;
    margin: 0 auto;
}

#HEADER{
    height: 15%;
    width: 100%;
    border-bottom: 2px solid black;
}

#CONTAINER{
    height: 85%;
}

#CONTENT{
    height: 100%;
    border-left: 2px solid black;
}

The CSS should control the following divs:


<body>
    <div id="HEADER">
        TITLE HERE
    </div>
    <div id="CONTAINER">
        <div id="MENU">

        </div>

        <div id="CONTENT">
            <asp:ContentPlaceHolder ID="CPH_Content" runat="server">

            </asp:ContentPlaceHolder>
        </div>
        <div id="FOOTER">

        </div>
    </div>

I have included the CSS in the head section of my HTML like this:


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Labo 2</title>
    <link href="/CSS/main.css" rel="stylesheet" type="text/css"/>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

I have also ensured that the external CSS file is accessible by adding the necessary authorization in web.config:


<location path="CSS">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>

If anyone could provide some guidance or explanations on why my CSS is not working properly, it would be greatly appreciated. JavaScript functions correctly, so it's specifically the CSS that's giving me trouble. Thank you!

Answer №1

Ah-ha, I've finally pinpointed the issue

To activate the % values properly, I realized that I needed to specify the html tag in addition to the body tag within the css file.

Everything is running smoothly now! Appreciate the assistance everyone!

Here's the modified code snippet:

html,body {
height:100%;
width:95%;
margin:0 auto;
border: 2px solid red;
}

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

Center column with header and footer flanking each side

Trying to replicate the layout of the Facebook Android app on my page. The app features a 3 column design, with the central column exclusively displaying the header (no footer included, although I require one for my version). This visual representation is ...

Generate PDF document from grid

While working with the obout grid, I encountered an issue when attempting to export the grid data to PDF. The export process worked seamlessly when populating the grid using sqldatasource. However, when filling the grid using a stored procedure and functio ...

Perpetual spinning of image grid

Are there any jQuery libraries available for continuous image rotation within an array? I have a collection of 30 partner logos that I would like to rotate continuously using either a jQuery library or plain CSS code. These images and information will be l ...

Retrieve the text input from its respective radio button

There are two radio buttons, each accompanied by an input text field. When a user selects a radio button, they can also enter some corresponding text. My inquiry is: What is the best method to retrieve the entered text for the selected radio button? ...

I'm curious about the meaning behind this code snippet: `$Odd = ($Odd == "even") ? "odd" : "even";`. Any ideas?

<?php $Odd = "even"; $query = $MySQLi->query("SELECT id, look, username, motto FROM users WHERE rank = '7'"); if($query->num_rows > 0): while($UserRow = $query->fetch_assoc()) { $Odd = ($Odd == "even") ? "odd" : "even"; ?&g ...

Trouble with AngularJs 1.x causing Bootstrap4 menu toggle collapse to malfunction

Issue with Navbar toggle menu not closing properly. I have attempted the solutions provided here and others in an effort to fix this bug. However, none of them seem to work for me. Here is a snippet of my code: <nav class="navbar navbar-expand-lg ...

Extract specific data points from external API responses on a webpage crafted in HTML

I require assistance on how to extract individual values from an HTML page. I received a response from the PAYU payment gateway team in HTML format, but I need to retrieve specific attribute values related to the transaction details. Below is the response ...

In Firefox, the focus outline is not shown on a div that has a mask-image CSS rule applied to

In my code, I have multiple div elements that have the mask-image and -webkit-mask-image CSS rules applied to them. These divs are being used as UI slider components, so I want keyboard users to be able to tab between them and use the arrow keys to adjust ...

Guide to obtaining context vnode within vue 3 custom directives

Unable to retrieve context from directive <template lang="pug"> div(class="form") select(name="name" v-model="form.input" v-select="form.inputs") option(v-for="(option, ke ...

Using Bootstrap CSS and JavaScript specifically for carousel functionality

Custom Styles and Scripts for Bootstrap Carousel Using Carousel with Controls https://getbootstrap.com/docs/4.0/components/carousel/ <div id="carouselExampleControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner ...

An advanced coding tool that is able to transfer CSS code from the style attribute to the class definition

Is there an editor or IDE that can convert styles from CSS classes to inline styles? .my_class { color: black; } <span class="my_class" style="font-size: 200%;">test</span> to .my_class { color:black; font-size: 200%; } <span ...

Customizing CSS for a Single Container

Recently, I've been tweaking the CSS for the selectMenu UI plugin in jQuery. I have a specific file where all my CSS styles are stored. My goal is to include this file on every page request but restrict its application only to my select menus, not ot ...

Navigate through information within designated boundaries

In order to achieve vertical scrolling of a sidebar div and its content (3 links) between two points, I have utilized the CSS property position:fixed; top: 100px. While this setup works well initially by positioning the sidebar 100px down from the top and ...

Adjust the background color of the dropdown menu

I'm struggling to change the background color of the property address picker dropdown from transparent to white. I've been trying different things but can't seem to get it right. Any suggestions? Additionally, I want to change the cursor to ...

Issues with div and hyperlinks/forms

I am currently working on creating a left sidebar in my HTML code, but I am still new to this. In the div for the sidebar, I have three buttons. However, Weebly keeps notifying me of an issue with the <a> tag, and the second button's link appear ...

Developing a simple ASP.NET class from scratch

Recently entering the .Net world, I am eager to dive into Object-Oriented Programming by creating a class. Within my .sln file containing multiple projects, I aim to develop a class that can take in 3 parameters: "stored proc name," "UserID," and "PageNam ...

Is it possible to utilize struts tags within HTML tags to set their attributes?

I have come across this code snippet but haven't tested it out yet: <input type="checkbox" id="<bean:write name="element" property="idvalue" />" /> Would this code work as intended? Additionally, are there more efficient ways to achieve ...

Tips for disabling default browser input validation in React

https://i.stack.imgur.com/834LB.png Is there a way to remove the message "Please fill out this field" while still keeping the "required" attribute intact? I have my own validation system in place, so I need to use the "required" attribute to determine whe ...

Setting up the Bootstrap grid structure

Struggling to find the right configuration for this Bootstrap 3 setup... https://i.stack.imgur.com/ZsTdI.png I have an input field, but I'm having trouble placing the image in that position. <div class="row"> <div class="col-sm-4 col-m ...

Pseudo-element fails to display in React when applied to a paragraph tag, even with display block property set

I am experiencing an issue where the pseudo element ::after is not appearing in my browser. I am currently working with React.js and Material UI's makeStyles. Here is the code snippet causing the problem: modalTitle: { borderBottom: '2px sol ...