Tips for formatting list items to display quotes in a scrolling ticker

How to format the <li> element

HTML:

<div id="patTest" style="width: 95%; padding: 0; margin: 0; text-align: center;">
        <ul id="patTestUL">
            <li>
                <div style="padding: 0; margin: 0; width: 98%;">
                <span style="background: #00ff00; width: 20%; text-align: right;"><img src="theImages/leftQuote.png" alt="Quote" style="width: 30px; height: 30px; padding-right: 10px;" /></span>
                <span style="color: #000000; background: #FF0000; width: 76%;">The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</span>
                </div>
            </li>
            <li>
                <div style="padding: 0; margin: 0; width: 98%;">
                <span style="background: #00ff00; width: 20%; text-align: right;"><img src="theImages/leftQuote.png" alt="Quote" style="width: 30px; height: 30px; padding-right: 10px;" /></span>
                <span style="color: #000000; background: #FF0000; width: 76%;">The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</span>
                </div>
            </li>
...
        </ul>
    </div>
</div>

CSS:

    <style>
        #patTestUL li {
             display: flex;
             justify-content: space-evenly;
          }
        .green-bg span {
          background: #00ff00;
          color: white;
          padding: 5px;
        }
        .red-bg span {
          background: #FF0000;
          color: black;
          padding: 5px;
        }
    </style>

This code snippet will now present the green and red sections separated and centered like this:

Answer №1

Include the following CSS properties inside the span that contains text:

display:inline-block;
vertical-align:top;

Check out the highest priority li element in this example: http://jsfiddle.net/Sarah_M/RK29B/

Furthermore, it is recommended to steer clear of excessive inline styles as they can complicate code maintenance.

Answer №2

Are you wondering if something like this will be effective?

Here is the HTML code:

<div id="patTest">
    <ul id="patTestUL">
        <li>
            <span class="quote">
                    <div class="image"></div>
            </span>
            <span class="box"></span>
        </li>
        <li>
            <span class="quote">
                    <div class="image"></div>
            </span>
            <span class="box"></span>
        </li>
    </ul>
</div>

And here is the CSS code:

* {
    padding: 0;
    margin: 0;
    list-style: none;
}
#patTest {
    width: 95%; 
    text-align: center;
}
li {
    width: 98%;
}
li > * {
    display: block;
    float: left;
    margin-left: 2%;
    margin-bottom: 10px;
}
.image {
    width: 30px; 
    height: 30px; 
    padding-right: 10px;
}
.quote {
    background: #00ff00; 
    width: 20%; 
    text-align: right;
}
.box {
    color: #000000; 
    background: #FF0000; 
    width: 76%;
    height: 50px;
}

To see it in action, click on this link: http://jsfiddle.net/5pkL5/1/

I only added the new classes from the CSS to the HTML for this demonstration. Just incorporate those into your elements as well.

The key to making everything function smoothly lies in using "float: left", "margin-left: 2%", and "margin-bottom: 10px". These properties ensure that the quotes and boxes align properly with each other and create the desired spacing.

Answer №3

Eliminating unnecessary markup from the example revealed that all I needed to do was style the list items.

<div id="patTest" style="width: 95%; padding: 0; margin: 0; text-align: center;">
    <ul id="patTestUL">
        <li>The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</li>
        <li>The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</li>
        <li>The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</li>
        <li>The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</li>
        <li>The art duo of Gilbert and George on how their work can ruffle feathers and the benefits of routine.</li>
    </ul>
</div>
#patTestUL li {
    list-style:none; text-align:left;
    position:relative; margin:.5em 0;
    background:red;  border:1px solid black;
}
#patTestUL li::before {
    content:'“'; position:absolute; left:-40px;
    font-size:70px; height:16px; width:34px; line-height:40px;
    background:lime; border:1px solid black;
}

JSFiddle.

If you want to include an image for the bullet, consider using list-style-image. Check out the updated fiddle for more information.

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

Is it possible to create .html files using the provided list of words?

Can we create .html files from a word list? Check out the example shown in the attached image. Thank you! View Image ...

Button group malfunctions on smaller screens

After integrating a button group into my new website, I noticed that the first two buttons stop functioning properly on smaller screens. Surprisingly, if I remove the text-center div, all buttons cease to work entirely. Despite attempting various solution ...

Determine a comparative measurement using specific numerical values

I am currently in the process of creating a webpage and I want to ensure that it is responsive by adjusting certain values based on the width of the viewport. Specifically, I have a DIV element that I want to split into 2 columns. For smaller screens (min ...

Generate a fresh DOM element when a particular height threshold is achieved, utilizing a portion of the previous DOM element's content

Update: 27th December 2016 The heading has been modified because any DOM element can be the target, whether it is a <p> element or not. Additional information has been provided about the tools being used and the desired outcome. Are there nativ ...

My HTML file seems to be ignoring the styles in my CSS file. What could be causing this issue?

I've started incorporating bootstrap 5 into my html page. Below is the code snippet: <link rel="stylesheet" src="/main_styles.css"> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" cla ...

Swap out a portion of HTML content with the value from an input using JavaScript

I am currently working on updating a section of the header based on user input from a text field. If a user enters their zip code, the message will dynamically change to: "GREAT NEWS! WE HAVE A LOCATION IN 12345". <h4>GREAT NEWS! WE HAVE A LOCATIO ...

Tips for expanding an md-nav-item in Angular Material

Need help on stretching the md-nav-item element illustration 1 ------------------------------------------------ | ITEM1 | ITEM 2 | ------------------------------------------------ illustration 2 ------------------------------------------------ | ...

html body extends beyond the negative position of the element

If you visit my website at this link, try resizing the window until the responsive design kicks in. Then, click on the "right" button at the top of the page. You'll notice that the right sidebar disappears and reappears, but when it disappears, the ba ...

What are my choices for showcasing hierarchical information?

I'm currently working on organizing hierarchical data using HTML, JS, and jQuery. My chosen method involves utilizing a left-floated div container system in place of a grid system for easier recursive code generation. One challenge I've encounter ...

Looking for guidance on sending data from a JS file to HTML using Nodejs? Seeking advice on various modules to achieve this task effectively? Let's

Looking for advice on the most effective method to transfer data from a JS file (retrieved from an sqlite db) to an HTML file in order to showcase it in a searchable table. My platform of choice is NodeJS. As a beginner, I am willing to put in extra time a ...

Converting Scalable Vector Graphics to Hypertext Markup Language and

So I've got this SVG file called 7.svg. What's the best way to show this image using HTML or CSS on my index.html page? ...

The hamburger menu is only functional for a single link

I've been developing a hamburger menu for my website, and it seems to be working fine until I click on a link. Once I navigate to a new page, the menu stops responding. To fix this issue, I attempted to use window.location.reload, which worked in Chro ...

What is the proper way to add comments within CSS code inline?

Can anyone provide instructions on how to comment an inline css property, such as height, in the following code snippet? <div style="width:100%; height:30%;"> Any help is appreciated. Thank you! ...

Is left padding appearing mysteriously (supernatural CSS phenomenon)?

While using the Firebug inspector tool, if you hover over #jimgMenu ul, you may notice that it has left padding without any corresponding CSS rule: Where is this mysterious left padding coming from? Why is the origin not visible? EDIT: If you navigate t ...

Setting up the Bootstrap grid structure

Struggling to find the right configuration for this Bootstrap 3 setup... https://i.stack.imgur.com/ZsTdI.png I have an input field, but I'm having trouble placing the image in that position. <div class="row"> <div class="col-sm-4 col-m ...

What is the highest value that AutoCompleteExtender can reach?

I am currently using an AutoCompleteExtender in my code with the following configuration: <ajaxToolkit:AutoCompleteExtender runat="server" ID="autoCompleteOrigem" TargetControlID="txtClienteOrigem" ServicePath="~/Cliente/Au ...

What is the best way to retrieve multiple image file names using JavaScript?

I attempted to use the code snippet below to retrieve the names of all the images I selected, however when I used 'alert', I only received one name even though I selected multiple. My goal is to have all the names of the selected photos saved in ...

Bespoke HTML, CSS, JavaScript, and PHP website designs within the Wordpress platform

I am a beginner in the world of Wordpress, coming from a background of creating websites from scratch. Currently, I am working on a Wordpress template (Astra) and looking to create a custom page using HTML, CSS, JavaScript, and PHP from the ground up to ad ...

I'm looking to adjust the position of an image inside a div without affecting the position of the entire div

When creating a horizontal navigation bar with an image, I encountered an issue where the image link did not align with the rest of the links on the navigation bar. I wanted to drop it down by a pixel or two without affecting the position of the other link ...

methods for transferring javascript variables to modal

<div> <h5> <a href="<?php echo base_url(); ?>/vendor/home/projects" >Return to Projects</a> </h5> <div> <div class="container"> <div class="row"> ...