Elegant Border Separator

I'm attempting to achieve the design below (with a 1 pixel gap on each end):

Answer №1

Experiment with the following code snippet:

<hr class="fancy">

Utilize the accompanying CSS for styling:

hr.fancy {
    border: 1px solid black;
    border-width: 1px 0px;
    color: black;
    height: 5px;
    position: relative;
}
hr.fancy:after {
    content: '\A';
    position: absolute;
    bottom: -1px;
    right: 0px;
    display: block;
    width: 1px;
    height: 7px;
    border-left: 1px solid white;
}
hr.fancy:before {
    content: '\A';
    position: absolute;
    bottom: -1px;
    left: 0px;
    display: block;
    width: 1px;
    height: 7px;
    border-right: 1px solid white;
}

View it in action here: http://jsfiddle.net/audetwebdesign/P7umD/

You can adjust the pixel values to achieve a more prominent appearance.

Cross-Browser Compatibility
Testing has shown consistent rendering in Firefox and Chrome.

However, please note that this technique may not be effective in IE9 where only double lines are displayed without the decorative ends.

Answer №2

Perhaps utilizing the border-image property could be the solution for your design needs.

Explore more about CSS border images at W3Schools.

For a different approach, consider using a div-based solution like this:

<div class="border">
    Content

    <div class="left"></div>
    <div class="right"></div>
</div>

.border {
    border-width:0px;
    border-style: double;
    border-color: grey;
    border-bottom-width: 3px;
    position: relative;
}
.left,
.right{
    position: absolute;
    width: 1px;
    height: 3px;
    bottom: -3px;
    background-color: white;
}
.left {
    left: 1px;
}
.right {
    right: 1px;
}

Check out this helpful demo on JSFiddle: http://jsfiddle.net/zCEKp/

Answer №3

If you're looking for a pure CSS solution, this might be what you need:

Here is the HTML markup:

<div class="customdivider">
    <div class="left">&nbsp;</div>
    <div class="middle">&nbsp;</div>
    <div class="right">&nbsp;</div>
</div>

And here is the corresponding CSS:

.customdivider {
    clear: both;
}
.customdivider .left {
    border-bottom: double black;
    width: 1px;
    float: left;
}
.customdivider .middle {
    border-bottom: double black;
    width: 50px;
    float: left;
    margin: 0 1px 0 1px;
}
.customdivider .right {
    border-bottom: double black;
    width: 1px;
    float: left;
}

This is how it will look once implemented:

http://jsfiddle.net/Lucidus/ZjGpS/1/ [edit: corrected the CSS in the previous link]

Answer №4

Is this the design you're looking for?

Check out the HTML code snippet below:

<div class="box">
        <div class="top-left"></div>
        <div class="top-right"></div>
        <div class="bottom-left"></div>
        <div class="bottom-right"></div>
</div>

And here's the CSS styling:

.box{
    position:relative;
    border:3px double;
    width:100px;
    height:50px;
}
.top-left, .top-right, .bottom-left, .bottom-right {
    position:absolute;
    width:4px;
    height:4px;
    border-left:1px #fff solid;
    border-right:1px #fff solid;
}
.top-left, .top-right{
    top:-4px;
}
.top-left, .bottom-left{
    left:-4px;
}
.top-right, .bottom-right{
    right:-4px;
}
.bottom-left, .bottom-right {
    bottom:-4px;
}

For a live demo, you can visit this jsFiddle link.

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

When using the .html() method on an object element with the Quicktime classid, Internet Explorer tends to

When utilizing .html() to fetch HTML that includes an object with param tags, IE8 will remove the latter and return an empty object element. Check out this jsfiddle showcasing the problem: http://jsfiddle.net/L9rra/1/. Update: Looking for a solution to re ...

I am having trouble with using document.getElementById().value to retrieve text input. Can anyone help me understand why it's not

It's puzzling to me why document.getelementbyid().value isn't working as expected. Upon inspecting the console, no input seems to be sent or printed out in the console. function callApi() { var keyword = document.getElementById('user_ ...

What is the method for showcasing an h1 heading and an unordered list link side by

Can you help me align my h1 and ul elements on the same line in my header? I want to have my logo and navigation links next to each other (This extra text is just filler) Below is the code snippet: HTML: <div id="header"> <h1>Logo</h1> ...

Creating layered images with CSS Grid

Visit this link for more details I've been attempting to create an overlap effect with 3 photos using CSS Grid. My desired outcome looks like this: Click here to see the desired result I followed tutorials that demonstrate the same method, but unfo ...

Ways to extract variables from a component and utilize them in App.js

Despite my efforts to search online, I could not find the answer or understand what I needed to. My issue: I need the "inputVal" variable from the "InputField.js" component to be accessible in the "App.js" component (specifically in the fetch request where ...

Incorporating a fixed header title when creating a customizable table

I am working on creating a dynamic table with rows and columns based on JSON data. JSON: $scope.dataToShow=[ tableHeder=["First Name","Age"], { name:"rahim", age:23 }, ...

Add JavaScript and CSS files from the node_modules folder to enhance a static HTML webpage

Currently, my development server is set up using node's live-server. However, for production, I plan to use a LAMP server. Within my node_modules directory, I have the normalize.css file. In my index.html, I currently link to it like this: <link ...

How can I write the code to enable dragging the button for navigating to the next page?

<a draggable="true" class="user" id="leonardo" ondragstart="dragUser(this, event)" aria-selected="undefined"> IPD</a> If I want the button to navigate to the next page when dragged, what code should I write? ...

How can you handle all HTML tags with Regex in a single line of code?

I've developed a PHP script that converts all inline CSS in HTML tags to classes. Visit the following link for more information: https://gist.github.com/iBars/aa52c6119e53908c91ac553aeba229e0 However, it currently only processes tags that are the onl ...

Determining the position of the selected option in an Angular 2 Select menu

Is there a way to retrieve the position of the selected option in a similar manner to the index of a table? Example for a table: <tr *ngFor="let car of cars; let i = index" (click)="showTabs(i)"> <td>{{i+1}}</td> </tr> I am lo ...

The combination of Google Maps and CSS transforms causes a blur effect on the page

After implementing the CSS Transform technique to center a div both horizontally and vertically, the desired effect was achieved. However, an unexpected issue arose on pages that contained a Google Maps iframe causing the entire page to go blurry. To view ...

Encircle a particular row in a table with a border

I'm having trouble creating a border around only the top row of my table. Right now, the border is only displayed around the outside of the entire table. I also want to add a border specifically to the first row that contains 'Team, Correct Picks ...

Ways to gather all the elements on each page

Currently engrossed in a web scraping endeavor for a car website utilizing Selenium. One potential roadblock I've encountered is that the code seems to only iterate over the initial car element on the page, instead of going through the entirety of ava ...

Tips for automatically filling out a div class form:

I currently have an Autoresponder email form featured on my webpage. Here is a snippet of the code for the section where customers enter their email: <div id = "af-form-45" class = "af-form" > <div id = "af-body-45" class = "af-body af-standa ...

The functionality of dropdown menus in the Bootstrap 5 navbar is currently experiencing issues

I recently updated my Bootstrap from v5.2.2 to v5.2.3 and now the dropdown menus in my navbar are not working properly. They do not drop down as they should, instead, they remain stationary. Can someone please help me figure out what I am doing wrong? & ...

jQuery Datatables have trouble accessing specific row information when the table is set to be responsive

Currently, I'm utilizing the jQuery DataTables plugin along with the responsive addon to dynamically display and hide columns based on the size of the browser window. One of the columns is labeled as Actions, which permits users to edit a record by c ...

jQuery's feature to select all elements except one and its children appears to be malfunctioning in Safari

My goal is fairly simple. I want to make the entire section clickable, except for the span and anything beneath it, so that the link redirects elsewhere. <section id="id" class="message"> <div class="message_body"> <font color="color"> ...

Rotate each row of the table in sequence with a pause between each flip

I have a table with 3 columns and 10 rows. I would like to flip each row one by one, where each row contains data on both the front and back sides. The flipping animation should be similar to the example provided in this link, but the flipping should sta ...

Java Script Custom Print Preview: A unique way to showcase your content

Is there a way to create a custom print preview dialog similar to the browser's print preview using Java Script? I am working on a book reader application that requires customization of the print preview dialog for page counting, automatic pagination, ...

Aligning a div within another div and organizing its elements

Hey everyone, I'm struggling with centering a div that contains two Tumblr posts columns, as shown in the screenshot linked below. I really want it to be centered on the page where there is no sidebar present. Additionally, I'm hoping to get the ...