Why isn't the DIV adjusting to the height of the text?

Can anyone help me figure out why the text is being cut vertically in my <div>? I thought it would adjust its height automatically. Thanks for any input.

http://jsfiddle.net/6LdfQ/

<div class="wrapper">
<div class="block-left bigtext">left</div>
<div class="block-right">right</div>
</div>

.bigtext {
    color: #333;
    font-weight: 600;
    font-size: 53px;
    line-height: 12px;
    text-align: right;
}

.wrapper {
    position: relative;
    display: block;
    margin-right: auto;
    margin-left: auto;
    width: 980px;
    overflow: hidden;
    background:red;

}   

.block-left {
    float: left;
    box-sizing: border-box;
    padding-right: 20px;
    width: 50%;

}
.block-right {
    float: right;
    box-sizing: border-box;
    width: 50%;

}

Answer №1

The bigtext class has been updated accordingly..

.bigtext {
    color: #333;
    font-weight: 600;
    font-size: 53px;
    line-height: 64px;
    text-align: right;
}

Remember, the line height should always exceed the font size..

Answer №2

The reason for removing the line-height css style is:

line-height: 12px;

This allows the <div> to adjust its height to accommodate the text.

Answer №3

The design flaw has been corrected to accommodate the text height specified at 12px. Review the updated CSS code below:

.bigtext {
    color: #333;
    font-weight: 600;
    font-size: 53px;
    text-align: right;
}

.wrapper {
    position: relative;
    display: block;
    margin-right: auto;
    margin-left: auto;
    width: 980px;
    overflow: hidden;
    background:red;

}   

.block-left {
    float: left;
    box-sizing: border-box;
    padding-right: 20px;
    width: 50%;

}
.block-right {
    float: right;
    box-sizing: border-box;
    width: 50%;

}

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

Text: The character code "f068" is displayed as "?"

I need to retrieve the content value from my pseudo element. script = "return window.getComputedStyle(document.querySelector('small.fa.text-muted.fa-minus'),':before').getPropertyValue('content');"; js = (JavascriptExecutor) ...

Adding an image in HTML from a different drive - step-by-step guide!

Currently, I am immersing myself in HTML, CSS, and JavaScript as I gear up for my upcoming school project centered around frontend development. Here's the issue I encountered. While attempting to insert an image into one of my HTML files, I ran into ...

DIV not displaying in a horizontal arrangement

I'm trying to get Box1 and Box2 to appear side by side, but for some reason Box2 keeps appearing below Box1. I've simplified the code to remove any links or references, but I can't figure out why they won't align properly. <%@ Con ...

Align the text to the center beneath the image using Jquery's append function

I am looking to showcase a collection of fruits and vegetables through images, with the names displayed centered underneath each image. Additionally, I want to implement jQuery append functionality so that the names only appear when a specific button is cl ...

Tips for Concealing PHP Undefined Error Messages Using Echo

I'm new to PHP and I'm attempting to display user information in a div after submission using the echo function. Here is my current code snippet: <label class="input-fields" name="cust-name"> Name <input type="text" id="cust[name]" ...

Need jQuery solution for changing CSS in numerous locations upon hover

Currently, I am working on a WordPress website and I am trying to figure out how to change the CSS color of a side navigation element when a remote image is hovered over. In a typical scenario, I would accomplish this using CSS by assigning a hover class ...

Minimize the gap between col-lg elements in responsive mode within Bootstrap

My website is built using Bootstrap 4 and the following is the HTML code: <div class="container"> <div class="row text-center "> <div class="col-lg-6">A</div> <div class="col-lg-6">B</div> </div> < ...

Transferring a selection from a dropdown menu

I am currently working on a dropdown menu where each entry has an ID and a value. The issue I am facing is that when I click on an item on the list, the click-handler is called and passes the div. While the click handler can access the id without any probl ...

Increase the identification of HTML element with jQuery

I've encountered an issue while trying to increment the id of 2 HTML elements, hwAddition and itemNumber, upon a button click event. The HTML code in question is as follows: <div id="hwAddition"> <div id="itemNumber" s ...

Add buttons to images to provide further explanations

While browsing the Excel Learn website, I came across a picture that displayed buttons explaining various functions in Excel. By clicking on the picture, a menu would open up to further explain the corresponding button. If you want to see this in action, ...

Whenever I try to access pages from the Menu, I keep getting a frustrating "Page not Found" error message due to the Handlebars rendering

I am currently working on a Menu website using nodeJS, and I prefer not to have all my html.handlebars in one file. I am facing an issue where my rendering is giving me a page not found error. What could be causing this? Let me share my project structure ...

Unable to get 'margin: 0 auto' to function properly on mobile devices

We recently created a website at but are facing issues with mobile device compatibility and centering the content using margin: 0 auto along with a specified width. The problem can be seen here: for "topuctovnici.sk" We have set .core to 1240px in widt ...

Developing an interactive single-page website

My goal is to develop a PHP web application with an overlay container that features dynamic fields/forms. The idea is for users to fill out the form without being redirected from the main page they are on. Imagine being able to report a page error on a w ...

Turning a multi-row table header into div elements using Javascript

Does anyone have a JavaScript algorithm that can analyze a table header and then output the equivalent DIV elements as either a string or object of DOM? The table header has the following structure: Here is an example of the HTML: <thead> <t ...

Give your screen a quick swipe with Ionic's pull-to-refresh

Is there a way to bring the footer of an ionic app closer for refresh or loading more content? I am particularly curious about how to implement the 'pull up to refresh' feature using HTML, CSS, or the Ionic content component. ...

Slider for comparing images is currently malfunctioning in Firefox

I recently came across a tutorial on how to create an image comparison slider, and it worked flawlessly on Chrome. However, when I tried to load it on Firefox, the slider didn't respond at all. Below is a snippet of the code: const slider = do ...

Achieve a seamless alignment of text/icons at the bottom of a row in BootStrap 4

Looking at this screenshot showing red and blue lines from a Firefox add-on called Pesticide: https://i.sstatic.net/h3Dmy.png Here is the code from the screenshot: <div class="row my-auto"> <p class="h6"> < ...

Checkbox inputs with activated labels causing double events to fire

Creating round checkboxes with tick marks dynamically and appending them to id="demo" on the click of two buttons that invoke the get(data) method is my current goal. The issue arises when both buttons are clicked simultaneously, as the checkboxes do not ...

What is the best way to arrange elements and create a cohesive layout?

I am currently working on a website and facing challenges in grasping the concept of alignment using CSS. I am struggling to align both text and image horizontally, ensuring they fit properly within the screen dimensions. Despite my attempts to modify diff ...

Using @Input to pass data from a parent component to a

Looking to modularize the form code into a separate component for reusability? Consider using @Input and referencing it in the HTML to pass values to the post method. Here's how you can achieve this: Previously, everything worked smoothly when all th ...