Creating a dynamic web design with HTML and CSS: how to overlay multiple styles of text on

Previously, I inquired about adding text to the gray area of an image. Some experts recommended using <span>, but this resulted in all the text appearing in a single line (as it is inline), even though it was set to display:block. How can I achieve separate lines of text as seen in the picture on the right? Additionally, should I use h4/h5 for styling or opt for different div elements?

HTML:

<div class="rightCol1"> 

    <a href="#"><img src="pic1.png"><span><h4>2014 02 16</h4><h5>most useful from the first stage <br> - osvaldas <br> sarpalius and lukas šukutis</h5></span></a> 

    <a href="#"><img src="pic2.png"><span><h4>2014 02 16</h4><h5>the best season start in club <br> history </h5></span></a>

</div>

CSS:

.rightCol1{
        float:right;
        margin-right:150px;
        margin-top:10px;

    }   

    .rightCol1 a {
        background:green;
        display: block;
        position:relative;
        height:200px;
        width:100px;
        margin-bottom: 160px
    }

    .rightCol1 a span {

        line-height:0px;
        display:block;
        margin-left:15px;
        width:234px;
        height:70px;
        position:absolute;
        bottom:-80;
        left:0;
        z-index:1;

    }

    h4{ 
        padding:0;
        margin:0;
        font-style:;
        color:#e6540c;
        font-weight:bold;
        font-size:14;
    }

    h5{
        padding:0;
        text-transform:uppercase;
        color:rgb(193,193,193);

    }

Answer №1

The reason for this issue is that the span element does not have a specified line height, causing each line to overlap. To fix this problem, I recommend removing the line-height property from your CSS for the span:

.rightCol1 a span {
    display:block;
    margin-left:15px;
    width:234px;
    height:70px;
    position:absolute;
    bottom:-80px;
    left:0;
    z-index:1;
}

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

Looking for a way to make CSS text color for a:hover have higher priority than a:visited?

I'm having an issue with my CSS code that changes the background color when hovering over a link. The text color is white on a blue background during hover, but if there is no hover, it's blue with a white background. Additionally, once the link ...

Utilize Flexbox and Material UI to position Item at the bottom of the layout

I'm attempting to include Unassigned Text at the bottom of my Container, following the layout shown in this mockup:https://i.sstatic.net/863cl.png Here is the code I currently have. I'm facing difficulty in getting the border between the play bu ...

Expand the <div> by clicking on it, then hover away to return it to its normal size

One interesting feature I have on my website is a <div> that expands when clicked, and returns to normal size with another click. However, I am looking for something a bit different... What I want is for the <div> (with the class name .topHead ...

Ways to integrate a CSS file into XSLT

I have a CSS file that looks like this: .table_class1DeffCell { border-top-width : 1; border-left-width : 1; border-right-width : 1; border-bottom-width : 1; } .table_class11DeffCell { border-bottom-color : 000000; border-top-color : 000000; border-right- ...

how can I incorporate PHP paths in my CSS?

I am attempting to assign a path to an image using a PHP variable in CSS, as demonstrated below: <?php $path= "www.ghhelpline.com/hello/images/" ?> <style> .hello { background-image: url("<?php echo $path;?>new.png") ...

What is the best way to manage a session using JavaScript?

Currently developing a website that initially hides all elements except for the password box upon loading. Once the user enters the correct password, all webpage elements are revealed. Seeking a solution to keep the elements visible on reload by utilizing ...

Exploring the css filter property in the Edge browser

Do CSS filters work in the Edge browser? -webkit-filter: blur(10px); -moz-filter: blur(10px); -o-filter: blur(10px); -ms-filter: blur(10px); filter: blur(10px); Unfortunately, none of these seem to be effective. Disclaimer: ...

A Bootstrap navigation sidebar with a secure footer and a div that can be scrolled

In the image below, you can see that the scrollable TreeView in the sidebar is not functioning properly. Additionally, I need to have a fixed footer for this sidebar that remains in place when users scroll through the content. How can I resolve this? http ...

Problem with the purity of :global() CSS-module selectors in NextJS

Currently in the process of migrating an app from CRA to NextJS, I've encountered an issue with the .module.scss files of certain components and pages: Syntax error: Selector ":global(.label-primary)" is not pure (pure selectors must contain ...

Incorporating pre-designed elements into the bottom section of my

I'm currently facing an issue while trying to integrate a footer content from a template into my slideout footer. The problem is that the template footer is currently spanning across the entire width of the page, and I am struggling to contain it with ...

HTML Canvas resizing challenge

My goal is to resize the canvas to fit inside its parent div within a Bootstrap grid, but I'm running into an issue where the canvas keeps expanding to 2000px x 2000px. Despite successfully resizing based on console.log outputs showing the same dimens ...

Some elements are not responding to margin-top properly

I am facing a problem where 2 elements are not responding to the specified margins of margin: 260px 0 0 0; or margin-top: 260px;. Despite inspecting the elements in IE's dev tools and confirming that the margin is set, the elements appear at the top o ...

After the first click, the .css function fails to work on the second click

THE MAIN CONCEPT: I have a collection of 16 blocks (div) and several buttons (a). Each button corresponds to a specific set of blocks. Initially, all the blocks are in the "ON" state. Pressing a button will turn off the related set of blocks, displaying t ...

Tips for avoiding repetitive animations when using jQuery animate toggle

Check out my Pen here. I'm having an issue with a share button that expands on hover. Everything works fine, except if you hover over it multiple times, the animation repeats as many times as you've hovered. Is there a way to prevent this from h ...

Here is a step-by-step guide on how to use JavaScript to eliminate the page title, URL, date and

When printing a page using window.print, is there a way to exclude the page title, URL, page number, and date/time from appearing? ...

On click, the current image should be replaced with the thumbnail image

I have been working on a project and came across a codepen link https://codepen.io/robgolbeck/pen/bVGmop that is similar to what I need. However, I am trying to achieve a specific functionality where clicking on a thumbs image replaces the large image with ...

How can I make the background image of an input text slide out of view when the "Enter" key is pressed?

The code is set up to slide out of view when the user clicks on the image, but I'm unsure how to make it do the same when the user hits "enter" in the input area. It's a bit frustrating... http://jsfiddle.net/mlynn/vxzc6z6y/ JavaScript code: ...

Access the document on the desktop and open it in a new popup window

As a novice in html coding, I'm wondering if it's possible to write window size and other properties directly into the page. Let me explain. I'm currently working on a calculator and I want to run the HTML file on my desktop. Everything wor ...

Can lines be visually represented within this specific div element?

I have a challenge where I am rendering data into a single div and I am exploring the possibility of using CSS to create three lines between the four columns. Even though it would be easier if I used separate columns with borders, I prefer the flexibility ...

Creating a collapsing drop down menu with CSS

I utilized a code snippet that I found on the following website: Modifications were made to the code as shown below: <div class="col-md-12"> ... </div> However, after rearranging the form tag, the drop-down menu collapse ...