Can the boundary of a div be softened or blurred?

My goal is to implement a design where each div of a specific class on my site displays a border that appears slightly separated from the content inside the div, similar to the example shown in this image (link below). Is there a CSS solution to achieve this effect?

https://i.sstatic.net/DQB6Y.png

Answer №1

If you happen to have the measurements on hand, give this a shot: http://jsfiddle.net/r4pmb7sd/

HTML:

<div class="picture-frame">
  <img src="https://i.imgur.com/pqoDSJX.jpg"/>
</div>

CSS:

.picture-frame{
  display: inline-block;
  border: 3px solid red;
  height: 300px;
  width: 300px;
}

.picture-frame img{
  margin-left: 10px;
  margin-top: 10px;
}

Answer №2

Utilizing pseudo code can yield the intended outcome.

.obscured {
  padding: 10px;
  position: relative;
  display: inline-block;
}

.obscured:before {
  content: "";
  position: absolute;
  border: 3px solid blue;
  top: -5px;
  left: -5px;
  width: 90%;
  height: 90%;
  z-index: -1;
}
<div class="obscured"><img src="https://via.placeholder.com/200x300"></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

Expand the number of columns from 12 to 16 on the largest screen size

In my current project, I am looking to have either 7 or 8 columns for the largest screen size using Bootstrap 4 (greater than 1200px). However, for screen sizes smaller than 1200px, the standard 12 columns suffice. Is there a way to modify the default Boo ...

Tips on obtaining a standalone text node using Selenium WebDriver

Is there a way to extract the text from a tag while excluding the text from nested tags? For example, if we only want to retrieve the string 183591 from within the <small> tag and not the text Service Request ID: from the <span> tag. The challe ...

Combining HTML, PHP, and Ajax within a single document

Hey everyone! I'm diving back into web programming and challenging myself to create a simple mailing form using just HTML, PHP, and Ajax all within a single file. The goal is to have a self-contained HTML document that doesn't refresh when the fo ...

Easy Access Form

I am working on creating a straightforward login form using HTML and JavaScript. The goal is to verify the entered username and password against a set list of authorized credentials upon submission. If the input credentials are correct, I want to direct t ...

Embed numerous HTML pages within a designated DIV by utilizing a list of hyperlinks

I'm currently facing an issue and can't seem to figure out the solution. I am looking for a way to achieve this without using PHP or JAVA as I am not proficient in those languages yet. The scenario is that I have 18 products/links and a single d ...

The hover effect seems to be disabled in the third-level submenu

I need help creating a dropdown menu that shows an image when hovering over a specific item. I have checked my CSS code and HTML structure, but the image is not appearing as expected when I hover over the "Afyon White" list item. Any ideas on how to fix th ...

Calculator for calculating values using JavaScript data attributes

One issue is that certain elements are canceling each other out.. The value of the element is specified in the "data-price" attribute. My code is currently not valid and does not handle it properly, ideally I would like to update the total whenever a selec ...

Creating Responsive Social Icons using HTML and CSS

Currently working on my portfolio website, but encountered an error. Can someone assist me in making my social icons responsive? I need the icons to be responsive and aligned horizontally for the mobile version. Here is a visual of the issue with the desk ...

What is the best way to make an image clickable in Next.Js?

Is there a way to turn an image into a link in Next.Js? I have the Instagram logo that I want to use as a link to my Instagram page. I want it to open a new tab and redirect the user to my Instagram account when clicked. I would really appreciate any guid ...

Apply a single CSS bounce animation to a specific div when clicked

I have implemented a CSS map pin with some CSS3 animations. You can check it out here: https://jsfiddle.net/xg7xfzeq/ body { background: #e6e6e6; } .pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: #00cae9; position ...

Implementing Custom Scroll Buttons in Bootstrap Modal Content

Trying to figure out how to create custom scroll up and down buttons for a Bootstrap 4 modal without the scrollbar that was hidden with CSS. I want to provide an easy scrolling option especially for those who might find using the mouse confusing. Is there ...

Display a new div with its content every 5th item

I am currently working with a Smarty template that contains the following code output: Check out my other question on Stackoverflow My problem lies in the fact that the provided code does not repeat the inserted HTML after every 5 elements... Could some ...

Ensuring the alignment of a personalized list bullet with the accompanying text

Looking to make the bullet point next to an li element larger? The common approach is to eliminate the standard point, add a custom one using the :before selector, and adjust the font size of the added point. While this technique somewhat achieves the goa ...

The Owl Carousel arrows and dots are perfectly aligned at the same level

When using the owl carousel, I encountered an issue where the arrows and dots are aligned at the same height. I would like to have the arrows centered vertically while keeping the dots at the bottom as they are currently positioned. However, whenever I att ...

Adjusting the view with a sliding tool

I am new to jQuery and want to create a compact plugin for my specific needs. My goal is to develop a simple timeline plugin that looks like the example below: The green bar below contains two small rectangles that can be dragged left or right to zoom in ...

Display the list items when the page first loads

I currently have this code snippet: <nav> <ul class="sel"> <li> <a href="#LINK1" data-title="A">A</a> </li> <li> <a href ...

What is the best way to showcase a ul element as inline-block?

Is there a way to keep the bottom menu aligned in one row on all screen sizes? I attempted using display: inline-block, but it doesn't seem to work for me. Below is the CSS code: footer #middle-footer { background: #F6F6F6; color: #000; font-size ...

What could be the reason that my d3.tooltip is not functioning properly for these specific two lines on the chart?

I am currently experiencing issues with the d3.tool tip for my line charts. Additionally, I would like to adjust the y-axis scale to create larger gaps between the lines. Below are the codes used to generate the line charts: <!DOCTYPE html> <meta ...

Halt the CSS transition on the preceding element

I tried to pause a CSS transition and came across a question with a solution that seems similar: Is there a way to pause CSS transition mid-way? However, I couldn't make it work for my code. I suspect the issue lies with the before element. What cou ...

Ensure the div has a scrolling feature activated when the content surpasses the height limit

I am attempting to make the middle div #content scroll when its content exceeds the available height (calculated as innerWidth - header height - footer height). However, rather than scrolling, the div has a scrollbar that is unresponsive, and the entire p ...