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

Experiencing problem with hover:after effect on Internet Explorer 8

I've been working on incorporating the CSS effect found on this website: Everything seems to be functioning properly except for the fix provided for IE8. I added some conditional code so that the fix is only applied to <= IE8, and as a result didn&ap ...

What is the correct method of implementing the "OnChange" event to a WooCommerce select element?

My task is to include the onchange="myFunction()" in the select menu below. However, because the select menu is part of woocommerce, I want to ensure that the onchange="myFunction()" remains intact even after updating my theme. How can I achieve this goal ...

Loading identical code in two different div elements

I am in the process of designing a comprehensive resource database featuring a side-scrolling container. Once a user clicks on a thumbnail within the container, the contents of a corresponding div will fade in and display specific category content. Each di ...

Utilize the class names to assign a distinctive color using mixins in SCSS

I am diving into the world of Sass and I have a peculiar challenge. I want to create a class that allows me to set a color using percentages for red, green, and blue values. For example, the class name color-50-10-60 would represent 50% red, 10% green, a ...

What is the best way to set a fixed width for my HTML elements?

I am facing an issue with my user registration form where error messages are causing all elements to become wider when they fail validation. I need help in preventing this widening effect. How can I achieve that? The expansion seems to be triggered by the ...

The table row's background image splitting into two halves

I am working on a table row class called logo, which has specific attributes. .logo { background: url("img/logo.png") no-repeat left top !important; } Currently, I have successfully placed an image at the top left of every row. However, my goal is ...

Initial page load experiencing issues with paroller.js functionality

Upon hard refreshing the page in the middle section, there seems to be an issue with the paroller js transform: translateY(); CSS effect not functioning properly on the <div class="col col-6" data-paroller-factor="0.4" data-paroller-type="foreground" da ...

Loading content dynamically with AJAX and enabling smooth page scrolling

Looking for a solution to this issue. I have a button on my webpage that, when clicked, uses AJAX to load content into a "div" element below the button. Everything functions properly except for one problem - every time the button is pressed, the page scrol ...

What is the best way to display form input fields depending on the selected value?

I've been struggling with a seemingly simple issue that I can't seem to find the right solution for, even after scouring Google. I have a form field for input and a select field with various values, including an "Other" option. Here's what ...

Navigating the screen reader with the cursor位

Site Design Challenge I recently discovered that the master/detail design of my website is not very accessible. The main view features a column chart where each column represents a different month. Clicking on one of these columns reveals details in a nes ...

Using NextJs to pass a prop as a className

I'm having difficulty figuring out how to pass a prop to a className, and I'm questioning whether it's even possible. For instance, if the prop category is passed into the function as "category1", can I use styles.category in the ...

Struggling with Implementing Modals in Bootstrap 3.3.7

I've been encountering an issue with modal functionality. In order to troubleshoot my own modals, I decided to replicate the modal example code from Bootstrap's website into a new HTML file. Despite linking to the CDN, the modal does not functio ...

Create a JavaScript button that redirects to a different page within a React application

I am creating a div element using a for-loop and I want to link each div to the "/campaign" page with its respective id. When a div is clicked, I want it to navigate to the "/campaign/id" page and pass the id to the Campaign component. class Home extends ...

To calculate the sum of input field rows that are filled in upon button click using predetermined values (HTML, CSS, JavaScript)

Greetings for exploring this content. I have been creating a survey that involves rows of buttons which, when clicked, populate input fields with ratings ranging from 5 to -5. The current code fills in one of two input fields located on opposite sides of ...

When you hover over the image, the text will disappear

When I hover over the image of LTC, a thumbnail appears with text and a button. However, I do not want the text "LTC" to be shown when hovering over the image. <div class="col-md-4"> <div class="view view-eighth"> <div class=" ...

What sets apart the intended usage of the DOM `hidden` from the CSS `visibility` property?

Exploring the DOM property hidden and the CSS property visibility, I find myself unsure of when to utilize each one. What are the distinctions in their intended purposes? While they may serve similar functions, I am curious about the underlying motivation ...

How to achieve divs with see-through text using CSS?

How can I create a CSS (non-HTML5) based website with a filled div that has a cutout revealing an image underneath? There are various overlays and images involved, making the use of static images inconvenient. Additionally, I anticipate needing to scale th ...

Exploring the World of Html

I'm struggling with an HTML problem related to a web programming class I'm taking. The assignment involves creating a video game using HTML and JavaScript, where an image moves randomly on the screen and the player must click on it as many times ...

Begin an unnumbered hierarchical list commencing at 1.2.1

I am trying to create a nested unordered list with specific numbering. My goal is for the list to start at "1.2.1, 1.2.2, etc." Please refer to the attached fiddle for reference. The desired outcome is shown in the following image: https://i.stack.imgur ...

Use a PHP form to send an email with HTML formatting, rather than plain text

I am facing an issue with sending emails from a web form. The received email needs to be displayed as HTML and not text. function createMailBodyLine ( $title, $value ) { $value = nl2br(htmlspecialchars($value)); return "<tr> ...