CSS/HTML - Issue with nested divs not displaying properly

Attached is an image that provides context for the issue I'm facing. https://i.stack.imgur.com/nQXh8.jpg

I'm encountering difficulties with styling a nested div element. When double-clicking the text within this div, only half of it gets highlighted.

Additionally, I need to ensure there's no gap between the wysiwyg editor and the header div.

The text editor I'm using is Django-ckeditor, which is being rendered by the {{form}} template tag since I'm building this application in Django.

This is the structure of my HTML:

<div class="hero clearfix">
    <div class="title">
        <h2>{{subsection_title}}</h2>
    </div>
    <br>
    <div class="subsection">
        <div class="subsection_header ">
            <h4 style="text-align:left">Something interesting.</h4>
        </div>
        <div class="subsection_body">
            <p>lol</p>
        </div>
    </div>          

And here's the corresponding CSS:

.subsection {
    width:1000px;
    margin:auto;
}
.subsection_header {
    border:1px solid #ccc;
    padding-left:20px;
    padding-right:20px;
    overflow:auto;
    margin:0px;
}
.subsection_body {
    margin:0px;
}

.hero {
    width:1000px;
    margin:auto;
    text-align:center;
}

.clearfix:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: " ";
    clear: both;
    height: 0;
}

Answer №1

Consider experimenting with the following code snippet based on your specific page width. Don't forget to properly close all tags.

.

main-container {
   position: relative;
   width: 1200px;
   margin-left: -600px;
   left: 50%;
}

This should provide some assistance for your webpage layout.

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

Adjusting font size, contrast, brightness, and sound levels on a website with the help of jQuery

My client has a new requirement: adding functionality to increase font size, adjust contrast/brightness, and control sound on his website. When clicking on any of the control images, a slider should appear for the user to make adjustments accordingly. Ho ...

Populate an HTML5 arc with an image - Leveraging the power of HTML5 Canvas

I'm working with an HTML5 Canvas (JSFiddle) that currently displays circles created using the following function: function createball(x,y,r,color){ context.beginPath(); context.arc(x,y,r,0,Math.PI*2,true); context.fillStyle = color; c ...

How to navigate to the "not now" button in Instagram notifications with Selenium and Python

I'm currently working on a custom "Instagram bot" to log in to Instagram. Although I've managed to bypass the login screen, I'm encountering an issue with a popup message that says: https://i.stack.imgur.com/OMA6h.png from selenium import we ...

What in the world is going on with this code snippet? I'm completely stumped on how to fix this problem

Attempting to generate a custom element with unique properties function y(){ var g=document.createElement("div"); this.label="elephant"; return g; } y.prototype.customFunction=function(){ alert(arguments[0]+this.label); }; var b=new y(); b ...

Is it possible to control my CSS using ModX Resources?

I have recently been experimenting with the ModX Revolution manager and had a question about converting my CSS into ModX Resources instead of files. I am interested in utilizing Templates and their variables as well. Do you know if this is possible? Also, ...

Is there a potential bug when using .fadeOut() within a hidden element?

After examining the code provided: <div class='hotel_photo_select'> Hello </div> <div class='itsHidden' style='display:none'> <div class='hotel_photo_select'> Hello </ ...

The performance of my Wordpress site is being hindered by the slowdown caused by Admin

I have a Wordpress website focused on winter sports vacations in Iceland: link Every plugin, WordPress core, and theme are up to date. Using Woocommerce for my online store. However, activating the Woocommerce plugin causes the site to slow down signific ...

How can you determine if multiple checkboxes have been checked with "if" statements following a button click?

I am looking to display a message after clicking a button if one or more checkboxes are checked. I would prefer using Jquery for this functionality. Any help on achieving this would be highly appreciated. $(function() { $(".btn").click(function() { ...

Selenium allows the liberation of a webpage from suspension

I'm facing an issue with resolving the suspension of a website as shown in the image below. My goal is to access a ticket selling website every 0.1 seconds, but if it's busy, I want it to wait for 10 seconds before trying again. Visit http://bu ...

Creating a tiled grid layout using Bootstrap 3

I’m grappling with a masonry layout issue while using Bootstrap. In my code, I have 5 divs but I’m struggling to get Div 4 and 5 to move up as shown in the attached image. While using margin-top is a quick fix, it disrupts the responsive design. Any su ...

Comparison of HTML's equivalent to LaTeX's label and ef functionality

I have a Frequently Asked Questions page coded in HTML (example) where the questions often refer to one another. This results in the numbering changing whenever we add, delete, or rearrange the questions. LaTeX provides an elegant solution to this problem ...

Error encountered when transitioning to TypeScript: Unable to resolve '@/styles/globals.css'

While experimenting with the boilerplate template, I encountered an unusual issue when attempting to use TypeScript with the default NextJS configuration. The problem arose when changing the file extension from .js to .tsx / .tsx. Various versions of NextJ ...

Using Radio button to access local HTML pages - A step-by-step guide

I am currently working on a project that involves the use of radio buttons and their corresponding options. My goal is to have each radio button selection lead to a specific HTML page being displayed. I've come across solutions involving external URLs ...

Preserve marked checkboxes upon page refresh

So I created a search engine with a filter using checkboxes in a form. The filter function is working fine when I submit the form (I'm using Flask for this). However, once the results are displayed, the checkboxes that were used as filters become unch ...

Encasing words within a cell of a table

My goal is to ensure that the table width remains fixed and unaffected by long text strings. Even though I have PHP code in place to limit characters at 100 per cell, I want to guarantee that a lengthy text string will never expand the table beyond its set ...

"Discover the process of using Puppeteer to extract information from a website, even when dealing with input fields that are set

I'm attempting to replicate the structure of a website using puppeteer, and here's what I have so far: page = await this.createPage(browser); page.setContent(await originalPage.content()); The issue arises from input fields in the DOM that are ...

It appears that the Facebook share feature is not picking up any meta OG tags

There seems to be an issue with my Facebook share functionality as it's not reading any of the meta tags. It is indicating that the required properties such as og:url, og:type, og:title, og:image, og:description, and fb:app_id are missing. <script ...

Adjusting the size of the snap increments

When using gridstack, I have the ability to resize my widgets. However, I've noticed that when dragging on the widgets' handles, they snap to specific sizes, which seems to be a fixed amount. If I wanted to set the widget's size to something ...

Difficulty encountered in closing div by clicking the background with the help of jquery

I am facing a challenge with properly closing a div container and restoring it to its original state when I click outside of it. Despite trying various solutions from stackoverflow and extensive internet research, I have been unable to find or come up with ...

Utilizing CSS grid layouts to ensure images expand to fit the dimensions of the designated column and

I am currently working with a CSS grid layout that is displaying as follows: .image__gallery-grid { max-height: none; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 2.5rem; dis ...