`To position an element within a div without affecting its layout, use absolute positioning``

Is it possible to add an element to a div that is aligned to the right but still sits on top of the other element within the div? Here are some images to illustrate the issue:

https://i.sstatic.net/dW7ev.png

The problem arises when you try to center the "Actions" text but the presence of the icon prevents it from taking up the full width of the div. Although I am currently using Bootstrap columns, they are not providing the desired solution.

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4b6bbbba0a7a0a6b5a494e1fae7fae4">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="066469697275727467762b6f6569687546372837362833">[email protected]</a>/font/bootstrap-icons.css">

<style>
.section-header {
            border-bottom: 1px solid var(--menu-dark);
            border-top-left-radius: 0.5rem;
            border-top-right-radius: 0.5rem;
            background-color: var(--menu-light);
            font-weight: bold;
        }

            .section-header .header-text {
                display: flex;
                justify-content: center;
            }
</style>

<div class="row section-header border border-dark">
  <div class="col header-text">Actions</div>
  <span class="col-auto"><a href="#" class="btn-edit"><span class="bi bi-pencil"></span></a>
  </span>
</div>
<div class="row border border-dark d-flex justify-content-center">
Test
</div>

Answer №1

Thank you for the request:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfada0a0bbbcbbbdaebf8ffae1fce1ff">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81e3eeeef5f2f5f3e0f1ace8e2eeeff2c1b0afb0b1afb4">[email protected]</a>/font/bootstrap-icons.css">
<div class="row section-header justify-content-end">
  <div class="col header-text text-center position-absolute">Actions</div>
  <span class="col-auto"><a href="#" class="btn-edit"><span class="bi bi-pencil"></span></a>
  </span>
</div>

Changes made:

  1. I included "justify-content-end" in the row to align the pencil to the right
  2. Added "position-absolute" to the element with "actions" to move it out of the regular flow and included "text-center" to center-align it

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

How to display and download a PDF file on a JSP web page

Can anyone help me with a simple trick to solve this question I have? In my project folder, I have 5 PDF files named file1.pdf, file2.pdf, file3.pdf, file4.pdf, and file5.pdf. I want to display these files in 5 rows on my webpage, each row containing VIEW ...

Download the PDF instead of just viewing or downloading it through a link

I need help configuring a link so that when the user clicks "download here," a PDF file is automatically downloaded to their desktop. Can someone provide guidance on how to achieve this? ...

What is the best way to implement CSS in this JavaScript Fetch code in order to manipulate the text's position and font style

Hello, I am just starting out with JS. Is there a way for me to customize the position and font of text in this JS Fetch function using CSS? Any help will be greatly appreciated. let file = 'art.txt'; const handleFetch = () => { fe ...

CSS animations - transitioning opacity in and out

Looking to add some CSS animations to a menu but running into some issues. I've got the code below for the menu to fade in on hover, but can't quite figure out how to make it fade out smoothly as well. I've tried a few approaches, but all I ...

The annoying Facebook "add a comment" popup refuses to close

Occasionally, the "add a comment" popup (iframe) in Facebook's Like plug-in fails to close and obstructs access to the content underneath. This issue has been noted while using Chrome 21 and Firefox 15. To replicate this problem, you can visit the fo ...

I can't seem to get my SVG data URL located inside an HTML file within an SVG data URL to display in Chrome

Background I am encountering an issue where an SVG data URL used as a background image property inside an HTML element within a <foreignObject> nested within an SVG data URL is not rendering properly in Google Chrome. If this structure was outside o ...

Eliminate the approximately 20 pixel space on the right side of the HTML email when viewed on iOS

Recently, I've been focused on developing a contact form for my portfolio website. Successfully sending HTML emails from the server to my email address has been a highlight. Since I mainly access my emails on my iPod Touch, I tailored the mail templat ...

The dropdown menu is erroneously showing buttons instead of the intended options

My dropdown function is causing a small issue. The desired behavior is that if the selected value is "", labeled "Please Select" in the dropdown menu (I've added a comment in the function to pinpoint the problem), then buttons A, B, and C should not b ...

Utilize WebGL to incorporate a mesh as a background image mask

Currently, I am faced with a challenge in WebGL that involves the following scenario: Picture a mesh positioned in front of the camera. This mesh does not have traditional shading, but its outline, or "silhouette," is utilized to display a background imag ...

Forget the function once it has been clicked

I'm looking for a solution to my resizing function issue. When I press a button, the function opens two columns outside of the window, but I want to reset this function when I click on another div. Is there a way to remove or clear the function from m ...

Adding or Deleting Rows from Input Table

I'm in the process of creating a website that features an input table allowing users to easily add or remove rows at their discretion. The desired UI is shown below: https://i.sstatic.net/EFAlM.jpg Here is the HTML code I have developed so far: & ...

Please submit information that is not already filled out in the text fields

I am looking to create a table with text fields and buttons as shown below: <table border="1"> <tr> <td>name</td> <td>id</td> <td>icon</td> <td> </td> & ...

Fluid percentage-based layout

I have four separate Divs that I would like to position on my page in a specific layout. Here is an image showing how I want them positioned: https://i.sstatic.net/KBZ1U.png In the future, I plan to add multiple svg files to Div 4 and I want it to be scro ...

Automatically pre-fill and send hidden form

I'm working on a form and have set up a handler for the submit button like this: $( '#submit_btn' ).click( function( data ){ theForm = document.getElementById( 'realForm' ); theForm.meetingName.value = document.getElement ...

Customize items within a bootstrap5 navbar by utilizing traditional CSS styling techniques

Hello everyone, I'm currently working on creating a navigation bar using Bootstrap 5. I am looking to customize the colors of certain elements such as the navbar, tags, navbar background, and burger menu. I've attempted to adjust the tags' c ...

Duplicate the PHP code for every section found within an INI file

<? $config = parse_ini_file('/list.ini', true); ?> <?echo'<select id="LBox" name="listbox" size="20" style="display:none;">'; foreach($config[MPR] as $id=>$label){ switch ($id) { case ($id== ...

Tips for keeping your content at the forefront of the page while incorporating fluid design elements and background hover effects

I'm facing some issues with the responsiveness of my layout. 1) I am noticing height discrepancies in my boxes when adjusting the screen width. Is there a way to resolve this using heights? 2) I have implemented a hover state using Jquery that darke ...

How come the changes in my react component's CSS are not updating in real-time?

After integrating redux into my create-react-app project, I've been struggling to implement a navigator that highlights the active "page link." To achieve this functionality, I am using a combination of react hooks (to maintain the current page state) ...

Although Angular allows for CSS to be added in DevTools, it seems to be ineffective when included directly in

Looking to set a maximum length for ellipsis on multiline text using CSS, I tried the following: .body { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; } However, this approach did not work. Interesti ...

When using setInterval, the image remains static on Safari but updates on Chrome

In my project, I am using a mock array to distribute data. One part of the project utilizes this data to display a list of cases, each with assigned images. When a case is hovered over, the images associated with that case are displayed one at a time, with ...