Using the <ins> element to push content into a separate div lower on the webpage

My text inside the <p> element is being pushed down by the presence of the <ins> tag. Removing the <ins> tag from the DOM using developer tools results in my text returning to its expected position.

main {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

#portal-wrapper {
    width: 100%;
    padding: 40px 0;
    background: #fff;
}

aside {
    width: 100%;
    padding: 10px 20px 20px;
    box-sizing: border-box;
    position: relative;
}

@media only screen and (min-width: 795px) {

    main {
        display: table;
    }

    #portal-wrapper {
        display: table-cell;
        min-width: 400px;
        max-width: 680px;
        width: auto;
    }

    aside {
        width: 300px;
        display: table-cell;
        padding-right: 0;
        padding-top: 41px;
    }

}
<main>
    <div id="portal-wrapper">
        <div id="portal">
            <p>
              Here's my text. Why am I pushed down so far.
            </p>
        </div>
    </div>
    <aside>
        <ins style="display: block; height: 600px;">      </ins>
    </aside>
</main>

Fiddle available at: https://jsfiddle.net/wwvq7net/1/

Answer №1

To align content at the top, you can utilize the vertical-align: top property:

main {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

#portal-wrapper {
    width: 100%;
    padding: 40px 0;
    background: #fff;
}

aside {
    width: 100%;
    padding: 10px 20px 20px;
    box-sizing: border-box;
    position: relative;
}

@media only screen and (min-width: 795px) {

    main {
        display: table;
    }

    #portal-wrapper {
        display: table-cell;
        vertical-align: top;
        min-width: 400px;
        max-width: 680px;
        width: auto;
    }

    aside {
        width: 300px;
        display: table-cell;
        vertical-align: top;
        padding-right: 0;
        padding-top: 41px;
    }

}
<main>
    <div id="portal-wrapper">
        <div id="portal">
            <p>
              Here's my text. Why am I pushed down so far.
            </p>
        </div>
    </div>
    <aside>
        <ins style="display: block; height: 600px;">      </ins>
    </aside>
</main>

JSFiddle

Answer №2

When using display:table-cell, the default vertical-align:baseline causes your #portal element to be pushed to the bottom of #portal-wrapper.

To resolve this issue, you can change the value to vertical-align:top or choose another appropriate value. For more information on vertical alignment, you can visit this resource.

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

Show or hide a specific element based on whether a certain radio button is selected or deselected

After successfully displaying an element on radio button selection, I encountered the issue of the selected element remaining visible when another radio button in the group is chosen. What aspect am I overlooking? Regarding hiding elements with vanilla Ja ...

The mobile screen size shortcuts are malfunctioning, while the regular links are functioning properly

ISSUE: Links in alias buttons are not working on mobile screen size, while normal links to other webpages like social media work fine. Description I created a project using an HTML, CSS, JS building tool from The project was exported and placed into a ...

Creating an XPATH Selector with SCRAPY

Having trouble retrieving the product name from a webpage: Struggling to locate XPATH that delivers a useful, specific result. Apologies for my initial question being quite basic :( class V12Spider(scrapy.Spider): name = 'v12' start_ur ...

The Bootstrap 4 column is not floating properly to the right as it is leaving a gap on the

My right sidebar is not floating to the right and has space from the right side. You can view it at this link: <div class="col-md-2 col-lg-2 col-sm-2" id="right-sidebar" style="background-color:orange; float: right; right: 0!important; width: 100%;"& ...

Achieving Perfect Alignment in Dreamweaver: Crafting a Stylish Header Container

Hello, I am currently working on a Dreamweaver site and have created a CSS style sheet within my template that includes a div tag called #HeaderBox. My goal is to make this box 40% of the screen's size, with specific pixel dimensions if necessary. I a ...

Can additional classes/styles be added to a CSS3 background?

Today I discovered that CSS3 has the capability to support multiple backgrounds, which is truly amazing. What I would love is the option to combine multiple backgrounds dynamically, like this: .Watermarked{ background: url('text/logo.png') bot ...

Exploring depths with nested ng-Repeat in Depth First Search

I am dealing with an object that has variable key names, each of which contains nested objects. My goal is to perform a depth-first search (DFS) over this object. For example, consider the following object: object = { "var1" : { "var2 ...

Converting HTML into an image in a Node.js Buffer

Can you suggest a simple method to convert a raw HTML string, like the following: <b>Hello World</b> into a regular PNG image in Node.js Buffer form? I've been exploring various npm packages for a solution that supports this functionali ...

Navigate to a hyperlink using an HTML tag on an Android device

Hi there, I have an HTML string that includes a tag with a href attribute. After setting this HTML string in a text view on Android, I want only the tag with the href attribute to be clickable and redirect to the appropriate link. Can someone please advise ...

Guide on stacking two divs on each other in response to a decrease in screen width

In this particular section, there is a div labeled programDescriptionDiv. Inside programDescriptionDiv, there are two separate divs. Normally, these two divs each take up 50% of the screen width. The goal is to have the second div stack below the first on ...

Unlimited horizontal slider control powered by HTML

In my quest to develop a slider control with infinite capabilities, I am looking for a way for users to slide left and right on a bar or panel, allowing them to navigate through past dates when sliding left and future dates when sliding right. While there ...

Enhancing jQuery UI popups with custom styles and layout

Currently, I am working on a web application that relies heavily on jQuery. To create popup windows, I have integrated jQuery UI dialog along with jQuery UI tabs and jScrollPane for customized scroll bars. The overall structure of the application is as fol ...

Is Your Website Sluggish because of an Excessive Amount of JavaScript on Page

After finally resolving some of the Javascript issues I was facing, I have streamlined my code to utilize just one library now, which is a huge improvement from how chaotic it was before. However, I have noticed a slight delay in the page load time, and I ...

Creating a straightforward text/logo design for your HTML website?

After creating a standard website using HTML and PHP, I am now looking to add an exciting text/logo effect for when users first visit the site. Essentially, I want the logo to break apart and transition into loading the homepage once a user lands on the si ...

The positioning of absolute CSS elements is causing alignment issues with their adjacent siblings

I am currently developing a customized Tooltip component using React that can be rendered to the right or below the target element. In my approach, the Tooltip component takes children as input and displays them. When these children are hovered over, the t ...

What is the best way to make a CSS change triggered by a onScroll() event stay in place permanently?

I need a div element to be displayed as a "scroll back to top" button on my webpage when the user has scrolled past a certain point. To achieve this, I am using the JavaScript code provided below: $(document).ready(function() { $(window).scroll(functio ...

Creating a 3x3 grid with CSS grid is great, especially when you want to place items in specific columns within the grid

I'm attempting to design a layout that has a unique structure: The blue rectangles are represented by divs. It's like a 3x3 grid, but with spaces in the 3rd and 4th columns of the grid. How can I incorporate these gaps using CSS grid to achieve ...

Canvas with a button placed on top

I am working with a canvas and trying to position an HTML element over it using CSS. My goal is for the button to remain in place on the canvas even when resizing the entire page. Here is the code I am currently using. https://jsfiddle.net/z4fhrhLc/ #but ...

Form Field Highlighting

I am currently attempting to eliminate the blue "halo" outline that appears on form elements in Firefox on OS X. I have successfully removed the halo in Safari on OS X using CSS with the following code: input { outline: none; } However, this method doe ...

Tips for disregarding global CSS in Nuxt.js?

I've been utilizing a boilerplate that integrates with the CoreUI template from GitHub, and it's been working well. However, I am now looking to customize my index page with a unique style, and I'm encountering issues where the global CSS fr ...