Place a gap at a specific spot within the boundary line

Here is a CSS code snippet that displays a horizontal line:

.horizontalLineBottom {
    border-bottom:solid #6E6A6B;
    border-width:1px;
}

Is it possible to add space at a specific position on this line?

For example,

______________________________________________

can be transformed into

______________________________             ___

Answer №1

A different approach using the border-width property:

.bar {
    width: 30px;
    height: 2px;
    padding: 0;
    border-width: 0 150px 0 200px;
    border-style: solid;
    border-color: blue;
}

http://jsfiddle.net/abc123/Xyz456/1/

Answer №2

:after or :before pseudo classes can be used for this purpose. Take a look at this Fiddle:

div {
    width:100px;
    height:100px;
    border:1px solid #000;
    margin:50px;
    background:yellow;
    position:relative;
}
div:after {
    content: '';
    height:60px;
    width:1px;
    position:absolute;
    top:20px;
    left:-1px;
    background:yellow;
}

Answer №3

Block without a border (only displaying a block with no border).

Feel free to include a background-image if it enhances the visual appeal.

Answer №4

Directly implementing this with CSS may not be possible. Here are a couple of alternative approaches to consider: 1) Incorporate the _ character into your design as a visual line and adjust spacing by inserting spaces where needed, then apply color styling with CSS. 2) Utilize two separate elements, assigning width and margin-right properties to the first element to create the necessary spacing.

Answer №5

To achieve a gradient effect on the element, consider using the CSS property background with a gradient. Check out this example on JSFiddle: http://jsfiddle.net/y49p3/. Feel free to customize the gradient as much as you want.

.line {
    margin: 10px;
    height: 1px;
    width: 400px;
    background:  -webkit-linear-gradient(
        left, gray 10%, white 10%, white 40%, 
        gray 40%, gray 60%, 
        white 60%, white 80%,
        red 80%, red 100%);
}

Answer №6

It may not be a direct solution, but there is a workaround that involves using a pseudo element. By creating a small overlay with the same background color as the element underneath, you can achieve the desired effect.

.verticalLineBottom { 
  position: relative; 
  border-bottom: 1px solid #6E6A6B; 
}
.verticalLineBottom:after { 
  content: ""; 
  position: absolute; 
  right: 20px; 
  bottom: -1px; 
  width: 100px; 
  height: 1px; 
  background: #fff;
}

For an example, check out this link: http://jsfiddle.net/zxdS7/

One limitation to keep in mind is that this technique may not work if the background behind your element contains a pattern.

Answer №7

With the code provided below, I have simulated the desired outcome for you.

.stopped-line {
  /* Include basic styles here */

  width: 100px; /* This is a required parameter */
  position: relative;
}
.stopped-line:before {
  position: absolute;
  bottom: 0;
  display: block;
  width: 70%; /* The line's width in percentage */
  content: " ";
  height: 1px; /* The thickness of the line */
  background: #000; /* The color of the line */
}
.stopped-line:after {
  position: absolute;
  bottom: 0;
  left: 80%; /* Define where the second line should begin */
  display: block;
  width: 20%; /* The width in percentage of the line */
  content: " ";
  height: 1px; /* The thickness of the line */
  background: #000; /* The color of the line */
}

Check it out on JSBin: here

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 new route in a Express JS server to specifically handle POST requests

Just starting to learn the ropes of Javascript, and I'm diving into express to create an application that will enable users to craft new recipes, explore existing ones, and view details about each recipe. To get things moving, I've launched my s ...

When clicked, check if the CSS value is equal to

I have no idea why it's not working. After toggleClass is executed, if the CSS value equals "-84%" then hide(); $(".rwd-sec").click(function() { $(".rwd-main").toggleClass("is-active"); if ($(".rwd-main").css("right") == "-84%") { ...

AngularJS: enhancing $http with custom functionality

I am facing an issue with my simple controller, which looks like this: function MyController($scope, $http) { ... $http.post(url).success(function(data) { console.log(data) }); } MyController.$inject = ['$scope', &ap ...

Enhance your WordPress menu with additional attributes

Currently, I am implementing a lightweight lightbox script on my WordPress website. My goal is to have one of the main navigation buttons open a Vimeo link in the lightbox. According to the lightbox documentation, I need to "Add the 'data-lity' a ...

What is the best way to update a specific section of my website by modifying the URL while keeping the menus fixed and the site functioning smoothly?

I am in desperate need of assistance as I search for a solution. Currently, I am working on a project involving music within a web browser or application. My goal is to utilize HTML, PHP, JS, and CSS to create this project. If I start with a website, I p ...

I have been unable to find a solution for the non-functioning jQuery (3.4.1 / 3.3.1) load() issue

I have been working with jQuery's .load() function Take a look at my code snippet: <html> <head> <meta charset="utf-8"> <title>load demo</title> <script src="https://code.jquery.com/jquery-3.4.1.js"> ...

Display all days on Highcharts, regardless of whether values are present or not

I am currently using PHP and MySQL to retrieve the total number of orders placed on each day within a specific time frame. I then save this information in a *.csv file using PHP. The chart that I generate from the csv file looks good, but I want to include ...

What steps are involved in merging Webflow code with an Angular web application?

As a newcomer to web development with Angular, I have the source code of a website already developed with Angular and I want to customize it to suit my needs. My issue is that when I add generated code from Webflow to an existing partial page, the browser ...

Property referencing for change detection is a valuable technique

I'm struggling to update my template when changing a boolean property that is referenced in another array property. I expected the changes to reflect in my template, but they are not showing up. Upon initial load, everything appears in its initial st ...

Exploring how to verify the data type retrieved from PHP using the jQuery post method

Understanding Data Types [{"id":"1","value":"Google"},{"id":"2","value":"Samsung"}] In programming, it's crucial to correctly identify the type of data you are working with. To help with this, I have created a custom function that determines the typ ...

Displaying content in a hidden div on click event

I am part of a volunteer group for prostate cancer awareness and support, and our website features multiple YouTube videos that are embedded. However, the page has been experiencing slow loading times due to the number of videos, despite them being hidden ...

After making a POST request, the `Req.body` is assigned to

This is the JavaScript code I am using: app.use(express.static(__dirname)); app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); // support json encoded bodies app.get('/', function(req, res){ res.sendFile(__dirn ...

Discover the specific item within an array of objects

Anyone have information like this: const info = { Title : "Banana", Quantity : 10, Location : "Everywhere", Phone : 123456, A : 987, B : 654, } and there is another array of details as: const dataArr = ["Title",&q ...

Tips on how to perform a server-side redirection to a different page in a Nextjs application without refreshing the page while maintaining the URL

I am working on a [slug].js page where I need to fetch data from an API to display the destination page. export async function getServerSideProps({ query, res }) { const slug = query.slug; try { const destination = await RoutingAPI.matchSlu ...

Importing modules dynamically in NextJS allows for the loading of

I have a basic function that is responsible for loading a script: const creditCardScript = ( onReadyCB, onErrorCB, ) => { let script = document.createElement("script"); script.type = "text/javascript"; script.src = process.CREDIT_CARD_SCRIPT; ...

Declaring a variable outside of a function or object

It's been a challenge for me to assign a value to the variable result as it always stays undefined. if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } ...

Transmitted only JSON data instead of using multiform data with jQuery Ajax

When I use jQuery Ajax to send a JSON object, it ends up being interpreted as 'multiform' instead of pure JSON. How can I make sure my request is sent as a pure JSON object and not multiform? var demo = new Array("One", "Two", "Three"); $.ajax ...

Run a function upon clicking a button in JavaScript

Could someone please help me figure out what I am doing incorrectly in the code below? I am attempting to trigger a function when a button is clicked. The HTML: <button id="btn1">Press me!</button> <input type="button" id="btn2" value="Pr ...

What is the best way to dismiss the additional modal popup?

Here is an example that I need help with: http://jsfiddle.net/zidski/Mz9QU/1/ When clicking on Link2 followed by Link1, I would like the Link2 box to close automatically. Is there anyone who can assist me with this issue? ...

Error: missing semicolon prior to the statement

I am looking to create a Java web application that includes a JSP page. However, when I load the page, I encounter the following error: SyntaxError: missing ; before statement The code for my JSP page is as follows: <%@ page language="java" contentTy ...