Adding content after text that has been wrapped is a simple process that involves

When the report generator creates orders in html, it uses absolute positioning to ensure the exact layout from the report designer is preserved.

Each order row contains a product description and price. Following the order row, there is a horizontal line or other content. If the product description wraps into multiple lines, a horizontal line should appear between each line of the product description:

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

Is there a way to fix this so that the horizontal line appears directly after the product description? It's challenging because the absolute positioning and hardcoded width cannot be easily changed, so they need to remain as they are. Could an inline layout or another method be used to ensure the div containing the horizontal line is rendered after the previous content?

The 'row' class has position: relative, yet for some unknown reason the horizontal line does not always appear after the product description.

<html>
<head>
<style>

.row {
  position: relative;
  clear: both;
}

.field-stretch {
  position: absolute;
}

.horizontalline {
  border: 1px solid #000000;
  position: relative;
  display: inline-block;
}

.field {
  position: absolute;
}    </style>
</head>

<body>

 <div class='row'>
<div class='field-stretch' style='width:9cm;'>Content wrapped to multiple rows aaaaaaaaa bbbbbbbbbbb ccccccccc</div>
  </div>

  <div class='row' style='min-height:0.5cm'>
<div class='field' style='left:8cm;width:2cm'>186</div>
  </div>

  <div class='row'>
<div style='width:9cm' class='horizontalline'></div>
  </div>
</body>
</html>

Answer №1

To display a horizontal line beneath, apply position: relative; and display: inline-block; to the specified class. You can enhance it further by adding a top value for better alignment.

.row {
  position: relative;
  clear: both;
}

.field-stretch {
  position: relative;
}

.horizontalline {
  border: 1px solid #000000;
  position: relative;
  /*display: inline-block; for additional spacing between content and line */
}

.field {
  position: relative;
}

body > .row:nth-child(1) {
  display: flex;
  align-items: center;
}
<html>

<head>
</head>

<body>
  <div class='row'>
    <div class='field-stretch' style='width:9cm;'>Content wrapped to multiple rows aaaaaaaaa bbbbbbbbbbb ccccccccc kkkkkkkkkkkkkkkkkkkkk</div>
    <div class='field' style='width:2cm'>186</div>
  </div>
  <div class='row'>
    <div style='width:9cm' class='horizontalline'></div>
  </div>
</body>

</html>

Edit ~ This is my recommended approach with no top values or strange margins. Absolute positioning may create issues, especially in responsive designs. By using flex on the first row, I demonstrate how content fills available space. Additionally, align-items: center; ensures proper alignment with product descriptions of varying lengths. Uncommenting d-inline-block under the line adds extra spacing. Feel free to ask if you have more questions.

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

While continuing to input text, make sure to highlight a specific element from the search results list

Currently, I am using a customized search feature in my React.js application. I am looking for a way to focus on an element within the search results so that I can navigate using arrow keys. At the same time, I need to keep the input field focused to conti ...

Show information - press the button on the current PHP page

After successfully reading files via PHP from a directory and dynamically creating a drop-down menu to view the file content, I have a query. Is there a way to display the text files' content on the same page without calling another PHP page? I know t ...

What would be the most appropriate way to organize the following data structure?

I'm facing a challenge with organizing content on a non-CMS website for the first time. I have about 250 individuals, each with a first name, last name, telephone number, email address, and some additional information. My initial thought was to use a ...

When I apply properties in JavaScript, I find that I am unable to utilize the CSS "hover" feature

For a personal project I am currently working on, I decided to experiment with setting background colors using Javascript. However, I have encountered an issue where my CSS code that changes the hover property does not seem to work after implementing the J ...

How to apply background-color to a div element with ng-repeat directive?

Hey there, I'm dealing with the following code: angular.module("myApp", []).controller("myController", function($scope) { $scope.boxList = [{ color: 'red' }, { color: '#F8F8F8' }, { color: 'rgb(50, 77, 32) ...

Generating an app without using the Jade template engine with Express

Interested in creating an express skeleton using the express generator method. Here are the steps: $ npm install express-generator -g But it tends to add a lot of automatic jade files, which can be overwhelming. Is there a way to eliminate those jade fi ...

Is it possible to apply a tailwind class that fades or transitions into something else after a specific duration?

How can I achieve a transition effect from the bg-red-300 class to bg-transparent, or a different background class, over a 2-second duration? Do I need to use javascript for this effect? I would like an element to be highlighted and then return to its no ...

CSS styles may not be consistently displayed or may vanish after being initially implemented

The colors and background remain unchanged. In previous projects, everything ended up falling apart Refreshing the page with F5 or CTRL + F5 does not make a difference. When using Open Live Server in VS Code, it initially shows the changes being applied b ...

Verify password criteria instantly

In my user registration form, users are required to enter a password that meets certain criteria such as containing 8 characters, numbers, and upper case letters. How can I indicate to the user if their password meets these criteria while they are typing? ...

Navigating a Bootstrap carousel with buttons: A step-by-step guide

Here is the code snippet I am currently working with: <!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-2.1.4.js"></script> <link href="https://code.jquery.com/ui/1.11.4/them ...

Have you ever wondered how the automatic video play on scroll feature works on Tiktok.com and YouTube shorts when using a mobile device?

My goal with React JS is to develop a website similar to Tiktok, where the video below will automatically play with sound as the user scrolls down. I attempted to set this up using window.addEventListener("scroll",...), but after looking into it further, ...

Encountered an issue when attempting to select the password field in order to log into a Google account using

Having some trouble automating the login process for my Gmail account. Managed to find the email element with an ID, but hitting a roadblock trying to locate the Password element as it doesn't have an ID. Here's what I've attempted: passw ...

Combining two kebab-case CSS classes within a React component

import React from 'react'; import styles from './stylesheet.moudle.css' <div className={styles['first-style']} {styles['second-style']}> some content </div> What is the correct way to include styles[&ap ...

Eliminate the curved edges from the <select> tag

Is there a way to eliminate the rounded corners on a select element? I attempted using the code below, but it resulted in removing the arrows and cutting off the bottom of the placeholder text: select { -webkit-appearance: none; -webkit-border-radius ...

Achieve a vertical fill effect within a parent container using CSS to occupy the remaining space

I have set my sights on a specific goal. https://i.sstatic.net/BqqTX.jpg This represents my current progress in achieving that goal. https://i.sstatic.net/unQY9.jpg On the left side, I have an image with a fixed height. The aqua color fills the left s ...

Should the value exceed the designated width of the combobox, it should be displayed across multiple lines

Having an issue where, when I set the width of the combobox and the value inside it is longer than expected, the full value isn't displayed. I am considering displaying the value on multiple lines to ensure the entire content is visible. Unfortunatel ...

Show the HTML code within the form with the identifier html-editor-form

I have four different sections which are displayed when the corresponding icon is clicked. The area labeled as visual-editor contains multiple HTML values. I am looking to showcase all the HTML values within the visual-editor class under the html-editor ...

What types of devices are compatible with the different versions of the Android operating system?

I am currently working on a jquerymobile application for Android versions 2, 3, and 4, as well as iPhone, iPad, and iPod touch. I am analyzing user-agent strings using jQuery and jquerymobile. After testing with an emulator, I have noticed that all device ...

Blend 2 text layers in HTML/CSS

I'm trying to create an effect where two titles overlap each other, with the white title appearing as a border around the black title. However, I'm having trouble figuring out how to achieve this. The light grey box represents the enclosing div. ...

What distinctions exist between setting width: auto; and width: fit-content;?

As far as my understanding goes, when you apply width: fit-content; to an element, it signifies that the element's width will expand to utilize all available space, but will not shrink below the min-content size within the element. However, does the d ...