What is a more effective method for presenting text alongside images in a seamless manner?

I'm having trouble aligning two labels of text inline under two images. The images are floating to the right, but when I try to float the text as well, it doesn't align properly underneath them.

I attempted to use a separate container for the label text, which did align the text under the images. However, the text was not evenly distributed beneath the two images as expected since they are in their respective containers.

I've tried various solutions but have not been successful so far. The text is within a span in its parent div, and the span #past-label is currently floating right, but not quite where it should be.

Hopefully, someone has a solution to this issue.

<article id="issue-wrapper">
    <div id="issue-container">
        <h5><span style="color: #ffffff;">First issue</span>  Fall 2010</h5>
        <h3>Heading</h3>
        <h6>Sub Heading</h6>
    </div><!----------issue container end---------->
    <div id="issues">
        <div id="past-cover"><a href="issues/sample-issue.pdf"><img src="image" alt="alt text" /></a>
            <span id="past-label">PDF</span>
        </div>
        <div id="past-cover"><a href="issues/sample-issue.swf"><img src="image" alt="alt text" /></a>
            <span id="past-label">FLASH</span>
        </div>
        <div id="past-cover-mobile"><a href="issues/sample-issue.pdf"><img src="image" alt="alt text" /></a>
            <span id="past-label">PDF</span>
        </div>
    </div><!----------issue covers end---------->
</article><!----------issue wrapper end---------->

<style type="text/css">
    #issue-wrapper {
        background-color:red;
        height:auto;
        padding:30px;
        display:table;
        width:100%;
    }
    #issue-container {
        width:30%;
        height:auto;
        background-color:gray;
        left:0px;
        display:table-cell;
        vertical-align:middle;
    }
    #issue-covers {
        background-color:orange;
        width:auto;
        height:auto;
        margin:0px;
    }

    #past-cover img {
        float:right;
    }

    #past-cover-mobile img {
        float:right;
        display:none;
    }

    #past-label {
        background-color:blue;
        margin:0px;
        width:auto;
        display:inline;
        float:right;

    }

    h5, h3, h6 {
        width:100%;
        margin:0px;
        font-size:2em;
    }
</style>

Answer №1

Try floating your #past-cover elements instead of the images. Also, make sure to set your <span> to have a display:block style.

Check out this JSFiddle for reference: http://jsfiddle.net/ghe73kdf/2

#past-cover {
        float: right;
    }
    #past-cover:after{
        display:table;
        clear:both;
        content:"";
    }
    #past-cover img {
        float:none;
        display:block;
    }

    #past-cover-mobile img {
        float:none;
        display:none;
    }

    #past-label {
        background-color:green;
        margin:0px;
        width:auto;
        display:block;
        float:none;
    }

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

Bottom section of a multi-level website with horizontal dividers

I was struggling with aligning divs next to each other, but I managed to find a solution. The only issue is that the text now aligns to the right instead of going below as it should. Typically this wouldn't be an issue since all content is within the ...

Using jQuery to extract the HTML content of an element while removing the style attribute

Is there a way to retrieve the raw HTML of an element, or obtain the HTML without the "style" attribute applied? Let's consider the example below: <div class="outer"> <div class="inner"> some text </div> </div> A ...

Add the onclick function to $(document).ready for applying the desired functionality

I've been trying to create a fading effect for 3 divs on my page, similar to the one in this example: http://jsfiddle.net/x4qjscgv/6/ However, I want the fade animation to trigger only when a user clicks a button. I attempted to use the document.getE ...

Issue with JavaScript HTML Section Changer not functioning properly

I need to implement a button that switches between two pages when pressed. Although the code seems simple, I am struggling to make it work. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"& ...

Removing background color when clicking and dragging using CSS

I'm facing an issue with a resizable div that is cropping part of my webpage. Whenever the mouse moves and clicks on the titles and images, a background color appears, as seen in the picture below. Can someone please help me resolve this problem? htt ...

Animating the width of an image with CSS3 animations

Looking to utilize CSS3 animations to shrink an image size when hovered over. Here's what I currently have: #logo-icon img { width: 80px; }; #logo-icon img:hover { width: 50px; transition: width 0.2s; }; However, the transition seems to be from 0px ...

Enhancing functionality by integrating Jquery/JS with input fields and labels

I am currently facing a challenge in applying CSS to the label element when the corresponding input is selected. After attempting and failing to use input:checked + label due to limitations in the HTML structure that cannot be altered, I seek alternative ...

observing which specific element corresponds to the nth child?

Exploring the concept illustrated in https://api.jquery.com/eq/, imagine a scenario with the following HTML structure: <ul> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> <li>list item ...

The navigation dropdown menu in Bootstrap 4 spills over the edges of the window

In the code snippet provided above, an example of a navbar with a dropdown menu is given. One issue that arises is when the dropdown menu is clicked and it overflows to the right, causing a horizontal scroll bar to appear on the window. The question at ha ...

Display a horizontal progression indicator during the page download process

Occasionally, website pages may take a while to download without the user even realizing it. This can be problematic if the user clicks on an image or button with an event handler attached, as it may break the page functionality. To address this issue, I ...

Design your own custom up and down arrow icons or buttons using CSS styling techniques

Is there a way to create "up and down" control buttons using only CSS and no background image? I attempted to add CSS for arrows in "li.className:after or li.className:before", but it caused the main boxes to move. Check out the Fiddle link to see the is ...

What is the best way to use html, css, jquery, and bootstrap to show or hide images without any extra space or alignment issues

I am looking to showcase 6 images on a page using the Bootstrap grid layout. The images should be displayed in two rows, with 3 images in each row. Additionally, I want to implement a filter functionality using Isotope, so users can click on a specific cat ...

Issue with retrieving body class in Internet Explorer on Magento platform. The body class is not being recognized in IE, but works fine in Mozilla and Chrome

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>" dir="ltr"> <?php echo $this->getChildHtml('head') ?> <bod ...

Aligning text appears fine in a full screen browser, but it can cause inconsistencies in appearance when resizing the window or viewing on a phone, as demonstrated in the

Hi there, I'm new to web design and I'm struggling to make my site look good on all screen sizes. I've created a page that should work well on any screen size: https://jsfiddle.net/garixakor/j0xck25v/1/ I attempted to center one of the par ...

Enable contenteditable on table by pressing the tab key

I developed a table entry tool and I would like to be able to input items by pressing the tab key instead of having to manually click on each element. I haven't been able to figure out how to make this function work yet. $('table').on(&apos ...

Dropdown search menus are failing to appear in the correct location

I have 4 dependent search dropdown menus side by side. There are two issues I am facing: Whenever I type in any of the drop-down menus, the MySQL-connected lists appear but not directly beneath the actual 'input-type-search-box'. Additional ...

Disabling the submit button after submitting the form results in the page failing to load

I am encountering an issue with my HTML form that submits to another page via POST. After the form validates, I attempt to disable or hide the submit button to prevent double submission and inform the user that the next page may take some time to load. He ...

Is there a way to regularly extract the most up-to-date HTML code from a dynamic website for designers to work

Our team of designers is responsible for creating graphical mockups, initial html, css, and image sprites for new designs. They also maintain these files. Once the hand-off is complete, our developers then take everything and work it into .Net code, templa ...

Arrange Bootstrap columns based on the available space within a loop

The content is contained within a md-8 div and generated through a PHP loop. The loop includes sections for: 1. about us 2. areas we cover 3. job board 4. candidates 5. join us 6. contact Due to the limited height of the "areas we cover" section, th ...

Detecting changes in checkbox states

In my current scenario, I have a section of the screen that can be shown or hidden depending on whether a checkbox is checked. The user can change the state of the checkbox manually or programmatically. The challenge lies in detecting this change and upda ...