Take a breather with a break in a div's outline

I'm looking to add a break on the right border of my div which already has an outline around it. Here's a visual example of how I want it to look like: (how I want it to look like)

Here is my HTML code:

<div class="carouseldiv w-75 mx-auto pt-5 customer-box-shadow">
CONTENT
</div>

And here is my CSS code:

.customer-box-shadow {
outline: 2px solid $red;
}

Answer №1

Utilize a mask to achieve transparency while also incorporating an inner shadow in place of the outline

.customer-box-shadow {
  box-shadow: 0 0 0 2px inset red; /* instead of outline */
  padding:50px;
  -webkit-mask:
     /* adjust the 60% to control the height of the cut */
    linear-gradient(#000 0 0) right/2px 60% no-repeat,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}


body {
  background:linear-gradient(90deg,#ccc,#fff)
}
<div class="customer-box-shadow">
  CONTENT
</div>

If outline is necessary, explore using clip-path for a similar effect

.customer-box-shadow {
  --d: 2px; /* outline border */
  --c: 60%; /* the cut */
  outline: var(--d) solid red;
  padding:50px;
  clip-path:
   polygon(calc(-1*var(--d)) calc(-1*var(--d)),
          calc(100% + var(--d)) calc(-1*var(--d)),
          calc(100% + var(--d)) calc(50% - var(--c)/2),
          100% calc(50% - var(--c)/2),
          100% calc(50% + var(--c)/2),
          calc(100% + var(--d)) calc(50% + var(--c)/2),
          calc(100% + var(--d)) calc(100% + var(--d)),
          calc(-1*var(--d)) calc(100% + var(--d)))
}


body {
  background:linear-gradient(90deg,#ccc,#fff)
}
<div class="customer-box-shadow">
  CONTENT
</div>

Answer №2

One way to conceal the border is by using another div as a cover, check out this example:

.bordered{
  display: block;
  width: 100px;
  height: 100px;
  border: 1px gray solid;
  position: relative;
}

.overlay{
  width: 25px;
  height: 25px;
  position: absolute;
  right: -12.5px;
  top: calc(50% - 12.5px);
  background: #fff;
}
<div class="bordered">
  content ...
  <div class="overlay"></div>
</div>

Answer №3

No need for any changes in markup. Utilize a pseudo element ::after to mask the undesired parts of the outline:

.customer-box-shadow {
  display: block;
  width: 100px;
  height: 100px;
  outline: 2px solid red;
  position: relative;
}

.customer-box-shadow::after {
  background-color: white;
  content: "";
  bottom: 30px; /* consider using a percentage here */
  right: -2px;
  width: 2px;
  top: 30px; /* consider using a percentage here */
  position: absolute;
}
<div class="customer-box-shadow">
  your content here...
</div>

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

HTML - maintain centered text positioning while implementing padding on the left side

Here are the HTML and CSS code snippets I am working with: #page { background-color: #000; color: #fff; height: 360px; width: 360px; min-height: 100%; } #viewport { font-size: 20pt; text-align: center; } .taskTitle { height: 13%; fon ...

What is the best way to keep wp_nav_menu expanded while accessing submenu links?

Recently, I joined the Wordpress community and am currently in the process of converting a static HTML site to the WP platform. Almost everything is working smoothly except for the navigation menu. I am attempting to utilize the built-in navigation featur ...

When a button is undersized, the click event may not register

In my angular application, I have developed a directive for a tinyMCE editor. Upon setup, I have implemented two handlers: one for the blur event to hide the toolbar and another for the click event to show it. Additionally, I have created another directive ...

Troubleshooting Angular 4's ng-selected functionality

I'm currently facing an issue with getting ng-selected to function properly. Initially, I attempted to simply add selected in the option tag, but later discovered that I should be using ng-select. Despite trying variations such as ng-selected="true" a ...

Why isn't the hover function working on the table row element?

When I try to apply a hover effect on tbody and td elements, it works perfectly. However, when I apply the same effect to the tr element, it doesn't work as expected. I am using inline style (js pattern) rather than CSS code and incorporating Radium i ...

Having trouble getting HTML to render properly in React JS on localhost using Apache server

For the past week, I've been working on resolving an issue. I started by creating a React Application using: npm create react-app After that, I attempted to build it with: npm run build Everything seemed to go smoothly. I generated a build folder ...

Why does the fillText() method in HTML5 Canvas erase everything after using the clearRect() method?

Whenever I use the writeTextToCanvas method before the clearCanvas method, everything works perfectly. However, if I call the clearCanvas method first and then writeTextToCanvas, the drawing functions work fine after clearing the canvas but the fillText fu ...

Retrieve data from an online JSON file

I am still learning about working with json and would appreciate some guidance. The data file I need to access is located at this url - I would like to display it in the following format: <ul id="smenu"> <li></li> </ul> Cou ...

Executing script once the DOM has completed loading

In my project, I'm dynamically generating menu items for a menu bar based on headers from external files that are imported using an XMLHttpRequest(). The menu bar is then updated as I navigate through different pages. Everything works smoothly. Each ...

Looking to locate .zip files using PHP Simple HTML DOM Parser?

Just started using PHP Simple HTML DOM Parser and I'm attempting to display links that have either a .zip or -animal.jpg at the end, but I seem to be stuck. I've done some searching online, but unfortunately, all I see below is a blank screen. ...

Prevent tooltips from displaying outside of an HTML table by using the overflow hidden property for horizontal scrolling

TL;DR: Struggling to position and display tooltips in a table due to the constraints of overflow: hidden. An example has been created to demonstrate the issue with tooltips not displaying correctly within a table. The problem arises because the table nece ...

Unable to retrieve the sum total of all product items and display it in the designated text element

My product items are dynamically generated in a list. I have used the calculateItemTotal() method to determine the total for each item. Now, I need to sum up all these item totals and display the result in the total text field. However, instead of showing ...

Creating a sleek drop-down menu using HTML and CSS

I am currently working on creating a drop-right menu using CSS, but I seem to be stuck... After searching for examples on the internet, I found that most of the code snippets are quite lengthy and overwhelming. I attempted to implement one of them, but t ...

Is it feasible to incorporate two distinct images into a single element using CSS layering?

I have a question about setting a background image for a web page using CSS. Currently, I have the following code: body { font-size: 62.5%; /* Resets 1em to 10px */ font-family: Verdana, Arial, Sans-Serif; background-color: #9D5922; color: #000; margin ...

Guide to retrieve the file name into a text box upon selection (Avoid displaying as c:/fake path/)

I am trying to achieve the functionality where after choosing a file in a file input, the file name is automatically displayed in a text box named file_name without needing to click or submit any button. Unfortunately, I have been unable to find the correc ...

Change the text in a CSS checkbox label when it is selected

There is an innovative Pure-CSS accordion that caught my eye, but I have a unique feature in mind that I would like to incorporate. What I am looking for is the ability for the labels to dynamically change based on the state of the checkboxes without relyi ...

Does anyone have any insights into the technology that powers Twiddla's browsing features?

After some observation, I came to understand that simply inserting <iframe src=remote-page-here></iframe> will not work as expected. Interestingly, the website twiddla does not use flash either. I am intrigued by how they achieve the in-place b ...

Tips for optimizing HTML5 markup elements to render effectively in Internet Explorer

How can I ensure that HTML5 markup elements such as <header>, <section>, and <footer> are displayed properly in Internet Explorer? I've noticed that when I apply CSS to these elements, the styling doesn't always work as expecte ...

Twig: A guide to showcasing HTML content within block titles

Within my Symfony2 project, I am utilizing various twig templates. One of these templates contains a block labeled title. {% block title %}{{ announcement.title }}{% endblock %} The issue arises when the variable {{ announcement.title }} contains HTML ta ...

Guidelines for validating email input using jQuery

Although I am not utilizing the form tag, you can still achieve form functionality using jQuery Ajax. <input type="email" placeholder="Email" name="email" /> <input type="password" placeholder="Password ...