Utilizing three columns within a <div> element

As I work on my Website using ASP.NET, I am customizing the MasterPage to divide the content into three columns within a div with specific widths for each column. However, I am facing an issue where the third column, which should be on the right, is instead appearing at the bottom of the div.

Another challenge I encounter is aligning all the information in the 80% width column to the center without using text-align:center in CSS.

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder id="head" runat="server">
        </asp:ContentPlaceHolder>
        <style type="text/css">
            table 
            {
               -moz-border-radius:10px;
               -webkit-border-radius:10px;
                border-radius:10px;
            }
        </style>
    </head>
    <body style="margin-top:25px">
        <div style="width:100%; height:80px; border:2px solid #000000; z-index:4; text-align:center;">
            <div>
                <h1>Title</h1>
            </div>
        </div>
        <div style="width:100%; border:2px double #ff0000; height:500px;">
            <div style="width:10%; border:2px dotted #ffd800; height:100%; float:left;">

            </div>
            <div style="width:80%; border:2px dotted #b6ff00; height:100%; float:left;">
                <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
            </div>
            <div style="float:left; border:5px dotted #ef8021; width:10%; height:100%;">
            </div>
        </div>
        <div style="bottom:0px; width:100%; height:75px; border:2px dashed #f117d2; z-index:0; text-align:center;">
            <div>
                <p>Visited <%=Application["mone"] %> people.</p>
                <p>Copyrights reserved.</p>
            </div>
        </div>
    </body>
</html>

Your insights are appreciated!

Answer №1

When you add a border to a DIV element, it increases the total width of the DIV. For example, if you have a DIV with a width of 100 pixels and you add a 1 pixel border, the total width will be 102 pixels.

If you want to visually distinguish areas of your page without affecting the size of HTML elements, consider using background colors for your DIVs.

Here is your page with the suggested changes (ASP.NET code removed for clarity):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder id="head" runat="server">
        </asp:ContentPlaceHolder>
        <style type="text/css">
            table 
            {
               -moz-border-radius:10px;
               -webkit-border-radius:10px;
                border-radius:10px;
            }
        </style>
    </head>
    <body style="margin-top:25px">
        <div style="width:100%; height:80px; border:2px solid #000000; z-index:4; text-align:center;">
            <div>
                <h1>Title</h1>
            </div>
        </div>
        <div style="width:100%; border:2px double #ff0000; height:500px;">
            <div style="width:10%;background-color:#f88;height:100%;float:left"></div>
            <div style="width:80%;background-color:#8f8;height:100%;float:left">
                CONTENT_PLACEHOLDER
            </div>
            <div style="width:10%;background-color:#88f; height:100%;float:left"></div>
        </div>
        <div style="bottom:0px; width:100%; height:75px; border:2px dashed #f117d2; z-index:0; text-align:center;">
            <div>
                <p>Visited # people.</p>
                <p>Copyrights reserved.</p>
            </div>
        </div>
    </body>
</html>

I hope this information is useful to you :)

Answer №2

<body style="margin-top:25px">
  <div style="width: 100%; height: 80px; border: 2px solid #000000; z-index: 4; text-align: center;">
    <div><h1>Title</h1></div>
  </div>
  <div style="width: 100%; border: 2px double #ff0000; height: 500px;">
    <div style="width: 10%; border: 2px dotted #ffd800; height: 100%; float: left;">Left Column</div>
    <div style="width: 79%; border: 2px dotted #b6ff00; height: 100%; float: left;">Center column</div>
    <div style="width: 10%; border: 2px dotted #ffd800; height: 100%; float: left;">Right Column</div>
  </div>
  <div style="bottom: 0px; width: 100%; height: 75px; border: 2px dashed #f117d2; z-index: 0; text-align: center;">
    <p>Visited <%=Application["mone"] %> people.</p>
    <p>Copyrights reserved.</p>
  </div>
</body>

It seems like the borders are causing the third column to extend beyond the available space, making it wrap out of the layout and into the row below.

UPDATE: I suspect that the content within your page is expanding the width of the central column!

You could check this by temporarily adding the "overflow: hidden;" property to your central column style.

<div style="width: 79%; border: 2px dotted #b6ff00; height: 100%; float: left; overflow: hidden;">Center column</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

HTML Autocomplete Error 404 Resolved with ASP.NET and JQuery

My autocomplete feature in an ASP.NET project is not working, despite trying different methods. I have set up a database called Diagnose, but when I try to implement it, I keep getting a 404 error on jQuery. Below is my HTML code: <script src="htt ...

Display a specific message in a div when the input field is left empty

My goal is to create a div that mirrors the content of an input field. When I type "lalala" in the input, it should show up in the div, and this part is working fine. However, I also want the div to display "The input is empty" when the input itself is emp ...

Tips for personalizing Ion text area in Ionic?

Seeking assistance on how to effectively utilize ion-textarea. As a novice in the realm of Ionic, I am encountering various challenges while working with this feature. The issue lies in the fact that instead of displaying a scrollbar on the right side, the ...

DotNetNuke encounters difficulties in running Jwplayer

I attempted to incorporate a jwplayer using the following code: <script src="js/jwplayer.js" type="text/javascript"></script><script type="text/javascript"> <script type="text/javascript"> $(document).ready(function() ...

Transfer the parameter from ajax function to the aspx.cs file

I've written some code using HTML, JS, and AJAX, but it's not functioning as expected. <script type="text/javascript"> function DeleteSelectedRecord(id) { alert(id); $.ajax({ type: "POST", ...

Why is it that lists always begin outside of the enclosing element?

I've always found this incredibly frustrating. Why do lists behave this way? When you set the margin and padding to 0, you would expect them to align normally with the surrounding text on the left, right? But no. That's where the text within the ...

Learn how to create a button that will only submit a value when clicked using Node.js and EJS

Currently in my ejs file, I have a button that sends a value to app.js instantly when the program runs. However, I want it to only submit the value when clicked by the user. <% notesArray.forEach((note,i) =>{ %> <div class="note"> ...

Tips for stopping html form from refreshing upon submission

Hello, despite extensive searching and testing, I am still unable to locate the issue and therefore I am reaching out to seek your assistance in resolving my problem. Within a form that I have created, upon clicking the submit button, a javascript functio ...

Displaying Json webmethod results in ASP.Net browser

I attempted to invoke a json webmethod from the browser, which is located in the code behind file. However, I am not receiving any output. In the json.aspx.cs page, the web method is defined as follows: [System.Web.Script.Services.ScriptService] ...

Lining Up Radio Buttons Horizontally Using CSS: Alignment Issues in Mozilla and Chrome

I have recently started learning CSS and am facing an issue with the alignment of radio buttons. They do not align properly in Chrome and Firefox, although they display correctly in Explorer. Any assistance on this matter would be greatly appreciated. Th ...

Activate the input autofocus feature when displaying a dialog in Vue.js

When opening a dialog with input text using v-menu upon clicking a button, how can I focus on the input text field? I have attempted to use $ref but it does not seem to work. newFolderClick(){ this.$refs["input_new_folder"].focus(); //it still appea ...

What are some ways to address the performance challenges associated with resizing images for responsive design?

When it comes to certain images, I find that scaling them based on the page size is the best way to make them responsive. <img class="img_scale" src="img.png" alt"this img doesn't have width and height definition"> In my CSS: .img_scale{wid ...

The transform operation has no effect whatsoever

Just a quick intro, I created an animated clock using CSS and HTML for homework, but now I want to enhance it by adding JavaScript functionality. I tried to sync the clock hands with the current time using JS, but for some reason, the animation always star ...

Event triggered before opening the cell editor in ag-Grid

I'm facing a scenario where I have a grid with rows. When a user double clicks on a cell, a cell editor opens up. There are events associated with the cellEditor - cellEditingStarted and cellEditingStopped, but I need an event that triggers just befor ...

Print the page number using HTML and PHP

Is there a way to center page numbers in HTML? I have the code below that echoes the numbers, but they always appear on the left side of the page. I tried wrapping them in a div to center them, which worked, but then each number is enclosed in its own d ...

Using jQuery to create a seamless transition in font size as you scroll

Currently, I have a jQuery animation function in place to adjust the font size of the .header-wrap text when the document is scrolled beyond 50px. While this method does work, I am not completely satisfied with it as the transition is not very smooth. Idea ...

Embedding PHP code within the value attribute of an HTML element is

Hey there! I'm looking to perform a database search and then display the results in a pre-populated HTML form for the user. I've pinpointed the issue in my code where PHP is not being recognized by the server. I'm currently using UwAMP. To ...

What is the process for extracting an image from a datatable?

Within my data table dtchild, there exists a column titled FILE_CONTENT where data is stored as an array of bytes. I am looking to extract the FILE_CONTENT data from this data table and convert it into an image format. Is there a way to achieve this? ...

The drop-down menu seems to have disappeared from sight

I'm having an issue with getting a dropdown to appear in my registration form. Everything else in the form is displaying correctly and functioning properly, but the dropdown remains invisible. After searching extensively, I haven't been able to ...

Achieving www prefix enforcement for loading js file

I am facing an issue with the script on my website, which is built using OpenCart. The problem arises when accessing the site with a www prefix - the JavaScript file fails to load. However, when accessed without the www prefix (e.g. example.com), everyth ...