Tips for removing the extra space below an element within a details element

When I have a details element and try to set its height to 100%, there is some space below the element, even when tested with a textarea and div.

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

I am specifically talking about the space between the red border of the .log element and the black border of the details element.

details {
    width: calc(100vw - 20px);
    box-sizing: border-box;
    border: 1px solid black;
    padding: 0;
}
.log {
    width: 100% !important;
    height: 100%;
    overflow-y: scroll;
    box-sizing: border-box;
    border: none;
    border-bottom: 1px solid red;
    outline: none;
    min-height: 50px;
    display: inline-block;
}
<details>
    <summary>Connection Log</summary>
    <div class="log" readonly>[08:33:43]: Connection</div>
</details>

<details>
    <summary>Connection Log</summary>
    <textarea class="log" readonly>[08:33:43]: Connection</textarea>
</details>

Is there a way to remove that extra space? I need this because I want to add a resizable corner (using a textarea).

Answer №1

To ensure proper alignment, include the CSS property vertical-align: top in your log class. This will help reserve space for descender characters like y, j, and g in inline elements:

details {
  width: calc(100vw - 20px);
  box-sizing: border-box;
  border: 1px solid black;
  padding: 0;
}

.log {
  width: 100% !important;
  height: 100%;
  overflow-y: scroll;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid red;
  outline: none;
  min-height: 50px;
  display: inline-block;
  vertical-align: top;
}
<details>
  <summary>Connection Log</summary>
  <div class="log" readonly>[08:33:43]: Connection</div>
</details>

<details>
  <summary>Connection Log</summary>
  <textarea class="log" readonly>[08:33:43]: Connection</textarea>
</details>

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 Align col-md-5 in the Center Using Bootstrap?

Is anyone else struggling with this dilemma or is it just me? I've been searching everywhere for a solution to my problem but I can't seem to find one. According to the grid system, if you have a column size of col-md-5, centering it should be ...

How to select the final td element in every row using JQuery or JavaScript, excluding those with a specific class

I am looking for a solution with my HTML table structure: <table> <tbody> <tr> <td>1</td> <td>2</td> <td class="treegrid-hide-column">3</td> < ...

refusing to display the pop-up in a separate window

Hi there, I'm having an issue with a link that's supposed to open in a pop-up but is instead opening in a new tab. I'd like it to open in a proper pop-up window. <button class="button button1" onclick=" window.open('te ...

Experiencing repeated triggering of ng-change on 'range' input in Chrome

When the range input is changed by sliding, the ng-change function continues to be triggered repeatedly until another element is clicked. This issue seems to occur only in the Chrome browser. You can view an example on this fiddle. Try sliding the element ...

Is there a way to adjust the sizes of images within a flexbox layout?

I am currently working on developing a website for my portfolio and I want to achieve a similar layout to this: https://i.stack.imgur.com/giJNF.png However, I am facing some difficulties with displaying the Twitter/Instagram and Deviantart icons. I am usi ...

Automatically synchronize dynatable with AJAX requests and JSON responses

I'm currently facing a bit of confusion as my code appears to be functioning properly, but the table is not updating as expected. xD I am fetching data from my database and loading it into a table, aiming for it to automatically update every three se ...

Is there a way to determine the negative horizontal shift of text within an HTML input element when it exceeds the horizontal boundaries?

On my website, I have a standard HTML input field for text input. To track the horizontal position of a specific word continuously, I have implemented a method using an invisible <span> element to display the content of the input field and then utili ...

CSS3 flip effect on hover and click causing issues

I have successfully implemented a card flip effect using CSS3. The card is flipped using jQuery and CSS CSS .flipped { -webkit-transform: rotateY( 180deg ); -moz-transform: rotateY( 180deg ); -o-transform: rotateY( 180deg ); transfor ...

how to combine a string in JavaScript using a prefix and suffix

Anion Gap Body Surface Area (BSA) Creatinine Clearance Stack Overflow i want to add "String" Before Text and "String" after end of text. I have Following expression which runs perfectly in excel:- =CONCATENATE("",B1,"") Output:- <string>Anion Ga ...

Is there a way to dynamically access BEM-style selectors using CSS modules?

For instance, I have this specific selector in my App.module.css file: .Column--active I want to access this selector from the App.js file in React using CSS modules. After importing all selectors from the CSS file as import styles from './App. ...

CSS: Containers displayed side by side when screen width is above a certain threshold, otherwise stacked on top of each other

I am trying to make two containers responsive without using media queries or JavaScript. When the screen size is 500px or less, I want the containers to stack on top of each other and take up 100% of the screen width. But when the screen size exceeds 500 ...

What is the best approach to ensure mobile responsiveness and properly space the TV show div?

How can I center the searched images of shows and add spacing below each image? The 12-column grid is not behaving properly and the images are aligned correctly on desktop but not on mobile. Any suggestions on how to fix this using CSS and Bootstrap? The g ...

Issues with Media Query in Mobile Device Footer not Resolving

Despite searching through numerous pages on Stack, I have not been able to find a solution. I am attempting to remove the footer on mobile devices using a media query. Unfortunately, it does not seem to be effective on the device, although it works when th ...

What is the best way to toggle DOM classes in React using Material-UI components?

Currently utilizing Material UI alongside React, I have a div element: <div className={classes.div}></div> I am attempting to dynamically add a conditional class to it: <div className={classes.div + divActive ? `${classes.div}__active` : &a ...

What steps do I need to take to create a basic API that links to a MySQL database?

I'm currently trying to develop an API for PHP that will enable one web server to communicate with another web server. Additionally, I want this API to be able to update MySQL code. Previously, I was utilizing $_GET parameters for this purpose but rea ...

Do my media queries accurately reflect the design?

I am new to web design and currently taking a course. As part of my assignment, I need to make my website responsive. However, I am having trouble with my media queries. Despite hours of research and tweaking, some elements are not responding as expected. ...

Vue-loader component experiencing issues with applying dynamic CSS styling

I'm working with a Vue Component and I want to enhance it by binding a color to a specific message. Initially, I attempted to achieve this using a binding like :style="styles" However, I encountered the following error: The property or method "st ...

Is it possible to use VBA to scrape the web for a specific style?

I've been on a quest to find a workaround for this issue but without any luck. All the data at my workplace is accessible through a web portal that generates static HTML pages. Unfortunately, my department doesn't have direct access to the Serve ...

Is there a way to turn off Emmet's CSS Abbreviations feature in Sublime Text 2?

One thing I really enjoy is how Emmet can generate HTML using 'CSS-like' strings. However, I prefer not to use their CSS Abbreviations. For example, when I write the following line of CSS: li a| I expect to get a tab when I press 'TAB&apos ...

What could be the reason for HTML not functioning properly in Bootstrap v5 Popover?

I am facing an issue where the HTML content I'm adding to a Bootstrap v5 popover is not displaying as expected. I have followed the guidelines provided in the documentation, but the results are not what I anticipated. Most of the information available ...