What is the proper syntax for creating a layout with DIV and CSS?

Is there a way to create a master page for asp.net that includes 3 sections using div elements? I want to split the window into a left pane for tree view navigation, a top banner type div, and a main content window under it where child pages will be loaded in the implementation of the master page.

Could you provide an example of the syntax needed for this layout?

Answer №1

If I had to choose, I would opt for a layout similar to this:

CSS Styles:

body {
    margin: 0;
    padding: 0;
}
div#left-column {
    display: inline-block;
    float: left;
    height: 100%;
    width: 30%;
    background: #A00;
}
div#top-right {
    display: inline-block;
    float: right;
    height: 30%;
    width: 70%;
    background: #000;
}
div#bottom-right {
    display: inline-block;
    float: left;
    height: 70%;
    width: 70%;
    background: #CCC;
}

HTML Markup:

<div id="left-column">
</div>
<div id="top-right">
</div>
<div id="bottom-right">
</div>

I've added background colors just for visual distinction. Wishing you the best of luck!

Answer №2

Expanding on Stann0rz's response, envisioning a master page and content view in action. This demonstration was crafted using ASP.NET MVC but can be easily adapted for traditional ASP.NET Webforms.

MASTER PAGE:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<style type="text/css">
    body {
        margin: 0;
        padding: 0;
    }
    div#left {
        display: inline;
        float: left;
        height: 100%;
        width: 30%;
        background: #A00;
    }
    div#top_right {
        display: inline;
        float: right;
        height: 30%;
        width: 70%;
        background: #000;
    }
    div#bottom_right {
        display: inline;
        float: left;
        height: 70%;
        width: 70%;
        background: #CCC;
    }
</style>
</head>
<body>
    <div id="left">
        <ul>
          <li>Navigation Item 1</li>
          <li>Navigation Item 2</li>
        </ul>
    </div>
    <div id="top_right">
        <span>Tab 1</span>
        <span>Tab 2</span>
    </div>
    <div id="bottom_right">
        <asp:ContentPlaceHolder ID="BottomRightContent" runat="server">
    </div>
</body>
</html>

CONTENT VIEW:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BottomRightContent" runat="server">
    [Insert bottom-right content here]
</asp:Content>

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

What is the best way to create spacing between images in a CSS image slider?

UPDATE: I've made significant progress by modifying the code provided in the link below. I am very close to achieving my desired result, but there are parts of it that still puzzle me. The transition now has spacing on both sides and the hidden space ...

Tips for making a div with a single triangular side using Reactjs

Hey there, I'm looking to design a header similar to the one shown in this image. Can someone provide guidance on how I can achieve this UI using React.js? ...

Is there a way to showcase posts with a certain tag in a single column on my tumblr theme, while reserving the other column for posts aimed at the wider audience?

I am interested in customizing my theme so that one section on the homepage of my blog only shows posts with a specific tag (such as "mine" or "personal"), while another section displays all posts, regardless of tags. Although I have searched through simi ...

Customizing error styles in a table using Jquery validation

My form is using JQuery .validation(). Here is the structure of my form: <form....> <table cellspacing="0" cellpadding="0"> <tr> <td>Name: </td> <td><input type='text' name='Name'/></td> ...

In Internet Explorer, transitions do not always play correctly when using ng-animate and ng-if

I am facing an issue with a simple div that has a transition effect. It goes from a yellow background to a red one. <div class="bar" ng-class="{'bar-visible': vm.visible}"> The transition works smoothly when the bar-visible class is added ...

What is the method for ensuring text remains within a square while it is being relocated?

Check out this jsfiddle where you can interact with a moving square: http://jsfiddle.net/helpme128/3kwwo53t/2/ <div ng-app="test" ng-controller="testCtrl"> <div id="container"> <div class="shape" ng-draggable='dragOptions& ...

What is the best way to use createElement in JavaScript to insert <p> and <span> elements within a <div>?

I am currently experimenting with generating sentences accompanied by draggable text boxes. To achieve this, I intend to construct the following HTML structure using JavaScript exclusively: <div> <p>Data1<span class = "smallBox droppabl ...

Unable to adjust the width of a datatable using the jQuery Datatable plugin version 10.1

I am facing a challenge with multiple datatables using the jQuery plugin on my page. Some of the datatables fit perfectly within the page width, while others extend beyond the page boundaries. Despite trying various methods, including setting styles in HTM ...

Incorporating a YouTube video

Having trouble integrating a YouTube video that won't play automatically on your website? The video is visible, but just doesn't start playing on its own. What could be causing this issue? Appreciate any help you can provide! ...

The CSS is not displaying correctly on Safari and Chrome browsers in Mac OS

I'm having trouble with CSS not loading properly on Apple devices for a website I made. Despite maintaining all media query statements and style sheets separately, the display is not correct in MAC OS safari and chrome. However, everything looks fine ...

I'm looking to showcase the list in a navigation bar by clicking on the hamburger menu. I want to include the 'home' and 'about' text specifically

Having trouble implementing the hamburger menu functionality in my HTML/CSS project. When clicked on a shrunken screen, I want the 'Home' and 'About' text in the nav to appear stacked on top of each other. JS is causing me some difficul ...

Discovering the window.scrollTop, ScrollY, or any other distance value while utilizing CSS scroll snap can be achieved by following these

I am currently utilizing css scroll snap for smooth scrolling through sections that are 100vh in height. The functionality of the scroll snap is quite impressive. However, I need to find a way to determine the exact distance the user has scrolled down the ...

Conceal specific image(s) on mobile devices

Currently, I am facing an issue on my website where I need to hide the last two out of six user photos when viewed on mobile or smaller screens. I believe using an @media code is the solution, but I'm unsure about the specific code needed to achieve t ...

Discover how to prevent a link or text from appearing if a user has already browsed a particular webpage

Is there a way to hide a link to another page if the user has previously visited that page? For example, I have 3 options - A, B, and C. If a user selects option A, links to pages B and C are displayed at the bottom of the page. However, if they then navi ...

Discovering visible ID numbers on the screen

My content includes the following: <div id="sContainer"> <div class="message0" id="l0">Initial Content 111</div> <div class="message1" id="l1">Initial Content 222</div> <div class="message2" id="l2">Initial ...

What is the best way to create space between three columns in Bootstrap?

Despite my efforts to find a solution on Stackoverflow, I have not been able to locate exactly what I need. I am trying to evenly space and center three columns across my page. However, when I assign col-md-4 to each column, they end up too close together ...

"Adjusting the Height of an MUI Autocomplete Input Field: A Simple Guide

I've been attempting to shrink the size of the Input field in MUI autocomplete but haven't had any luck. Here's the code I tried: styling: autocompleteStyle: { height: '2.3rem', color: `${theme.palette.grayDark1} !important ...

What is preventing jQuery from returning a string or text value?

index.html <button id="fetchGroupers">Fetch Groupers</button> <script type="text/javascript"> $(document).ready(function () { $("#fetchGroupers").click(function () { $.ajax({ type ...

The issue of the container div tag not being able to achieve 100% height and width

My web page layout has a CSS issue where I am unable to achieve 100% height in Firefox and Chrome, unlike in Internet Explorer 9. I have tried multiple examples but encountered the same problem. You can view the code on http://jsfiddle.net/cwkzq/3/ where i ...

Grid X Transformation 3: Dynamically alter grid cell background based on value (no need for CSS classes)

While working with GXT2, it was possible to dynamically change a cell's background color using the GridCellRenderer's render method. However, in GXT3, this feature no longer exists. The suggested approach is to utilize a GridViewConfig and overri ...