What are the steps to creating a gradient for the bottom border?

SAMPLE TEXT:

Hi there, I am looking for assistance in designing a bottom border with a gradient and transparent edges.

Any suggestions on how I can achieve this effect?

Answer №1

One way to achieve this effect is by utilizing a pseudo element, which has better browser support compared to using a border-image.

html,
body {
  margin: 0;
  padding: 0;
  background: #222;
}
hr {
  position: relative;
  height: 0;
  border: 0;
}
hr:before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  height: 5px;
  width: 100%;
}
.demo1:before {
  background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%,rgba(255, 255, 255, 1) 50%, rgba(255, 255, 255, 0) 100%);
}
.demo2:before {
  background: linear-gradient(to right, rgba(179, 220, 237, 0) 0%, rgba(41, 184, 229, 1) 50%, rgba(188, 224, 238, 0) 100%);
}
.demo3:before{
  background: linear-gradient(to right, rgba(182,224,38,0) 0%,rgba(177,222,39,1) 50%,rgba(171,220,40,0) 100%); 
  }
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<hr class="demo1" />
<br />
<hr class="demo2" />
<br />
<hr class="demo3" />

Please keep in mind:

  • The necessary prefixing has already been taken care of by the prefix-free script.
  • In the provided example, a hr element was used for demonstration purposes. However, this technique can be applied to other elements that support pseudo elements like div, a, p, etc.

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

Creating a character jump animation on an HTML5 canvas

While following a tutorial on creating character animations, I encountered an issue. The tutorial, located at , made it easy to make the character move left (the right movement was already implemented). However, I am struggling with how to animate the char ...

Is there a way to choose an option from a select form using a button?

Currently, I have a fully functional form set up like this: <form name="form1" method="post" action="process.php"> <p> <label for="numbers"></label> <select name="select"> <option selected disable ...

The website appears to be experiencing technical difficulties as the complete content

Check out this website: The full page content is not displaying properly. The footer content seems to be hidden and only appears after refreshing multiple times. Can anyone diagnose if there might be an issue with the CSS or JavaScript? ...

Preserve the button interface when it is clicked

Just diving into the world of CSS for the first time with a front end styling task, so apologies in advance for any errors or misunderstandings! I have a placeholder button that triggers a Modal (1): https://i.sstatic.net/1wT9Y.png When clicked, the but ...

Can you explain the purpose of using "link href="#""?

While browsing through the source code of a website, I came across this interesting snippet. <link href="#" id="colour-scheme" rel="stylesheet"> I'm curious, what exactly does this code snippet do? ...

Add a picture and adjust its size as needed

Currently facing an issue where I am attempting to upload an image and display it on screen in a draggable and resizable manner. Utilizing jquery for the draggable and resizable functionalities, the problem lies in the fact that the draggable function is f ...

Aligning a block of text containing two varying font sizes in the center

I'm attempting to center a paragraph element with a span inside that has a different font size, causing the alignment to be slightly off. Below is the HTML code: <p class="priceWrap"><span class="moneySign">$</span>60000.50</p> ...

CSS fluid divs floating on a single line

Imagine having a series of images with text below them, all wrapped in a div and centered. There are 20 of these elements with similar image sizes but varying amounts of text. The goal is to line up as many as possible on one row, each with 10px margin on ...

Develop a dynamic animation using gradient and opacity properties

I'm still getting the hang of HTML, JavaScript, and CSS but I recently made some changes to someone else's code to animate a gradient. The original code used background: rgb, but I switched it to background: rgba. It seems to be working fine, but ...

React CSS Modules - Adding styles to individual child elements

I'm having difficulty applying CSS styles to each child of a specific tag. I am using CSS modules in conjunction with semantic-ui-react: character.module.css .Character > GridColumn { border: solid 4px red; } character.js import React, {Com ...

The Bootsrap 5.3 navbar is not fully extending to the width of the page

My goal is to have the list items in a Bootstrap navbar stretch across the width of the page in mobile view, but I'm having trouble achieving this. I've tried following various tutorials without success. I even attempted using *{margin:0;padding ...

How to align icon and text perfectly in a Bootstrap 5 Button

I am looking to align icons and text within a modal body: <div class="modal-body"> <div class="d-grid gap-2" id="someButtons"> </div> </div> This code snippet demonstrates how I insert buttons ...

Form Submission in C# Triggered by Empty Required HTML5 Fields

After creating a sign-in form using HTML controls and running them server-side to use in C#, I encountered an issue. <button id="btnSignIn" class="btn btn-lg btn-info btn-block" type="submit" runat="server" onServerClick="btnSignIn_ServerClick">Sign ...

Creating a banner using four grid elements, with each element containing four child elements, is a simple process that can

Can you assist me in recreating my idea from an image? I am having trouble understanding how to select and place other elements, and then return them to their original positions after deselecting... I attempted to use a grid but it did not work properly. ...

Display a <button> element as a text hyperlink within a paragraph, ensuring proper wrapping and flow

I want to incorporate a link-styled <button> within a block of text while ensuring that it flows smoothly with the surrounding content. Although styling the button is straightforward and setting display: inline allows it to blend into the text flow, ...

Tips for avoiding a 500 GET error due to an empty request during page loading

I recently encountered an issue with a form containing a dependent drop-down menu that reloads after form submission to preselect the main choice that was made before submission. The problem arises when the page initially loads without any parameters being ...

The Image Slider functions smoothly in Chrome, but encounters issues in IE11

Here is a link to the code I've been working on: http://jsfiddle.net/wf32jbhx/ I attempted to host images on my SharePoint site, but they ended up stacking on top of each other instead of formatting properly. Oddly enough, everything appears fine in ...

Stylish dots emerging under navigation bar

Okay, so I've run into a simple issue, but I can't seem to figure out the solution. Ever since I wrote this code, I've noticed these small dots appearing below the menu. Take a look at the image for a clearer picture. https://i.sstatic.ne ...

The overflow hidden function does not seem to be fully functional on the iPad

Struggling to prevent body scrolling when a modal pop-up appears? I've tried setting the body overflow to hidden when opening the modal and resetting it when closing, which worked fine on desktop browsers. However, mobile devices like iPod/iPhone pose ...

Is it possible to manipulate an image tag's image using only CSS?

Is it possible to hide an image from the src attribute of an <img> tag and instead set a background image on the tag using CSS? One idea could be adjusting the positioning or text-indent of the actual image to move it out of view, and then applying ...