Adding style to the `li` elements before the attribute

Is there a way to modify the border color on an HTML element?

ul.timeline>li:before {
  content: ' ';
  background: white;
  display: inline-block;
  position: absolute;
  border-radius: 50%;
  border: 3px solid #22c0e8; /* Change this code to modify border color */
  left: 20px;
  width: 20px;
  height: 20px;
  z-index: 400;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container mt-5 mb-5">
  <div class="row">
    <div class="col-md-6 offset-md-3">
      <h4>Latest News</h4>
      <ul class="timeline">
        <li>
          <a target="_blank" href="https://www.totoprayogo.com/#">New Web Design</a>
          <a href="#" class="float-right">21 March, 2014</a>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque scelerisque diam non nisi semper, et elementum lorem ornare. Maecenas placerat facilisis mollis. Duis sagittis ligula in sodales vehicula....</p>
        </li>
        <li>
          <a href="#">21 000 Job Seekers</a>
          <a href="#" class="float-right">4 March, 2014</a>
          <p>Curabitur purus sem, malesuada eu luctus eget, suscipit sed turpis. Nam pellentesque felis vitae justo accumsan, sed semper nisi sollicitudin...</p>
        </li>
        <li>
          <a href="#">Awesome Employers</a>
          <a href="#" class="float-right">1 April, 2014</a>
          <p>Fusce ullamcorper ligula sit amet quam accumsan aliquet. Sed nulla odio, tincidunt vitae nunc vitae, mollis pharetra velit. Sed nec tempor nibh...</p>
        </li>
      </ul>
    </div>
  </div>
</div>

For more information and examples, visit:

Answer №1

Do you need to insert a border between two blue circles and remove the default ul style?

I've included some custom css code for your reference below.

  • To eliminate the default ul style, I've specified list-style-type as none.
  • To create the vertical line that connects the list items, I have utilized a pseudo class element :before with ul.timeline.

ul.timeline {
    list-style-type: none;
}
ul.timeline:before {
    content: ' ';
    background: #d4d9df;
    display: inline-block;
    position: absolute;
    left: 29px;
    width: 2px;
    height: 100%;
    z-index: 400;
}
ul.timeline>li:before {
  content: ' ';
  background: white;
  display: inline-block;
  position: absolute;
  border-radius: 50%;
  border: 3px solid #22c0e8;
  left: 20px;
  width: 20px;
  height: 20px;
  z-index: 400;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container mt-5 mb-5">
  <div class="row">
    <div class="col-md-6 offset-md-3">
      <h4>Latest News</h4>
      <ul class="timeline">
        <li>
          <a target="_blank" href="https://www.totoprayogo.com/#">New Web Design</a>
          <a href="#" class="float-right">21 March, 2014</a>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque scelerisque diam non nisi semper, et elementum lorem ornare. Maecenas placerat facilisis mollis. Duis sagittis ligula in sodales vehicula....</p>
        </li>
        <li>
          <a href="#">21 000 Job Seekers</a>
          <a href="#" class="float-right">4 March, 2014</a>
          <p>Curabitur purus sem, malesuada eu luctus eget, suscipit sed turpis. Nam pellentesque felis vitae justo accumsan, sed semper nisi sollicitudin...</p>
        </li>
        <li>
          <a href="#">Awesome Employers</a>
          <a href="#" class="float-right">1 April, 2014</a>
          <p>Fusce ullamcorper ligula sit amet quam accumsan aliquet. Sed nulla odio, tincidunt vitae nunc vitae, mollis pharetra velit. Sed nec tempor nibh...</p>
        </li>
      </ul>
    </div>
  </div>
</div>

Answer №2

Here is a simple way to create a timeline using only Bootstrap classes, no extra CSS needed. The use of the border utility class helps in creating the lines for the timeline.

    <!-- timeline item -->
    <div class="row">
        <!-- timeline item 1 left dot -->
        <div class="col-auto text-center flex-column d-none d-sm-flex">
            <div class="row h-50">
                <div class="col">&nbsp;</div>
                <div class="col">&nbsp;</div>
            </div>
            <h5 class="m-0">
                <span class="badge badge-pill bg-light border">&nbsp;</span>
            </h5>
            <div class="row h-50">
                <div class="col border-right">&nbsp;</div>
                <div class="col">&nbsp;</div>
            </div>
        </div>
        <!-- timeline item 1 event content -->
        <div class="col py-2">
            <div class="card">
                <div class="card-body">
                    Timeline item content....
                </div>
            </div>
        </div>
    </div>

Visit this link for more details.

Answer №3

You have the freedom to customize the border color to your liking. Kindly refer to this screenshot to see how we implemented it in a live example:

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

What is the best way to manage the gradual disappearance of multiple divs belonging to the same class using jQuery?

I need help with a hover effect for 6 divs on a page. Each div has a layer on top that fades out on hover and fades back in on mouseleave. I currently have code for each individual div layer, but it's causing a stack overrun. How can I assign this fun ...

Specifying a zero margin on a Bootstrap container does not remove the margin

I am trying to make my right container elements fill the entire width of their column. After inspecting in Chrome, I noticed that my bootstrap container had default margins on both sides. To fix this, I set the margins to zero. Although the left margin di ...

I am having trouble with Owl Carousel in my code. Can anyone help me figure out what is causing the issue

I'm having trouble getting my owl carousel to display when I try to run it. I've made sure to link the correct stylesheets and scripts, but nothing is showing up on the page. Even after trying to link the stylesheets from both a local source and ...

Implementing *ngFor in Angular 2 to render a clickable email address within a table row

I am working in TypeScript with an array of objects: array: [ { prop1: 'string1', prop2: this.createEmailLink('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfaaa2aea6a38faaa2aea6a3e1aca0a2">[email ...

Pros and Cons of Using HTML5 Mode versus Hash Mode in AngularJS

When using AngularJS 1.3, it is necessary to include the <base> tag in HTML5 mode. This led me to consider the pros and cons of HTML5 mode versus Hash mode. In Hash mode, the major drawback is that URLs can appear unattractive and may not be easy fo ...

Implement custom styles using media queries within ngView to ensure compatibility with IE browsers even after a page

Experiencing issues with CSS rules in IE10 when included in a page via ngView (using Angular 1.0.6). Works fine in other browsers (potentially IE11, not personally confirmed): Here is the CSS code: .checker { display: none; } @media (min-width: 1041 ...

retrieve data from html to store as NSString

I have extracted an HTML string from a UIWebView using the following code: NSString *html = [webview stringByEvaluatingJavaScriptFromString: @"document.documentElement.innerHTML"]; The content of the NSString is as follows: <head> <meta name= ...

Center a Bootstrap 4 card both vertically and horizontally without overflowing the screen

I am facing an issue with a single page layout where I have a centrally positioned card containing a form and text. Once the form is submitted, a list is displayed. However, sometimes the list is lengthy causing the card to cut off at the top with no scrol ...

Ajax activates a slider

One element I have is a menu div, along with a content div Initially, when the slider (which is a jquery plugin) is placed in the index.php, everything appears to be working well, as shown in the image below However, my objective is to have each page&apo ...

Enhance React scrollbar functionality without relying on third-party dependencies

Currently working on enhancing the appearance of the scrollbar within my ReactJS project. Specifically, I am aiming for a design similar to this example: https://i.stack.imgur.com/2Q0P4.png Experimented with CSS properties like -webkit-scrollbar, -webki ...

Mastering the art of integrating HTML5's localstorage feature with Jquery's select2 plugin

Is it possible to integrate HTML5's localstorage method with Jquery's select2 plugin? Currently, all entered data disappears when the browser/tab is closed, leading to potential confusion if you forget what was entered. Here is an example of my ...

Trouble with image size transition not functioning properly

When attempting to enlarge an image with a transition in Chrome, it doesn't seem to be working properly. Here is the HTML code: <img src="foobar.png"> And the CSS code: img { float: left; margin-right ...

Introducing the new default in Google Chrome: Now accessing window.opener for target="_blank" links after rel="noopener" is the standard feature

Exploring a new attribute called rel="noopener", I discovered that it keeps opened windows unaware of their opener. After some experimentation, I consistently found window.opener === null, only to realize that this is now the default behavior in ...

How Do I Go About Setting the Background Color for the Body Element?

Having trouble setting a background image for the body correctly. My colleague passed me an SVG file to use as the background, but it's not displaying properly. Here is what I need to set in Adobe XD: https://i.sstatic.net/ayZxW.jpg And here is the ...

What is the best way to show a message next to a text box in a form?

I have a form called test.php with two buttons for entering an email ID and user ID, as well as a submit button. Upon clicking the submit button, my code checks if the email ID exists and displays a message to the user. I want to show this message next to ...

Expanding list item with jQuery

I am facing an issue with the dropdown functionality of my <li> elements. The problem occurs when clicking on the 4th option, as the expander appears on top instead of dropping down beneath the list item. If you check out this jsFiddle, you can see ...

Explore the limitless possibilities of using jQuery Superscrollorama with fixed backgrounds

I am looking to achieve a scrolling effect with multiple elements, specifically three pictures in this case. While it is easy to implement scrolling, my goal is to keep the background fixed during the scroll event and have it move once the scrolling is co ...

Vertical alignment of label in the middle of the page is malfunctioning

Check out this fiddle for placing text in the middle of the page vertically. Fiddle HTML: <label class="label"> This text should be centered </label> CSS: .label{ vertical-align: middle; } Despite setting the CSS property, the text is ...

Creating a form-group in Bootstrap 4 with a layout that includes two sets of labels and inputs on each

Check out the code on Codepen here. The initial form showcases two sets of labels and elements positioned next to each other. My goal is to group each pair of <label> and <div> within their unique containers: div.myFormColumnLeft and div.myFo ...

Using Angular to implement floating input labels with typeahead functionality

I recently implemented a style from this source: http://tympanus.net/Development/TextInputEffects/index.html If you want to create an input directive, check out the example on Plunker: https://plnkr.co/edit/wELJGgUUoiykcp402u1G?p=preview While it works p ...