Creating a border with a unique and specific image

Is there a way to use an image as the border for my div elements?

The key requirement is that the border must be positioned outside the box without affecting its size. It's important to note that all div items have the same width, but varying heights.

I am aiming for a result like this:

Here is the border image I want to use:

.container {
  display: flex;
  justify-content: space-around;
}

.product1 {
  width: 200px;
  height: 500px;
  background-color: blue;
}
.product2 {
  width: 200px;
  height: 550px;
  background-color: green;
}
.product3 {
  width: 200px;
  height: 520px;
  background-color: red;
}
.item {
  border: 20px;
  border-image: url("https://dc614.4shared.com/img/2uaeGtwfea/s23/17d090b76b0/border-1")
}
<div class="container">

<div class="product1 item">
123
</div>
<div class="product2 item">
123
</div>
<div class="product3 item">
123
</div>

</div>

Answer №1

To achieve the desired effect, it is important to specify both the color and mode:

.box{
    border: 15px solid #333;
    ...
}

It's worth a try - I'm no expert in web development but I have dabbled in it and this solution could potentially work.

Answer №2

It seems like the border-image may not be the best solution for your current situation. I have come up with an alternative method to achieve the desired appearance.

To create the desired effect, I inserted a <span>NEW</span> element with absolute positioning inside each .item element. If adjustments are needed, you can modify the top and right css attributes accordingly.

.container {
    display: flex;
    justify-content: space-around;
 }

.product1 {
    width: 200px;
    height: 500px;
    background-color: blue;
 }
 .product2 {
     width: 200px;
     height: 550px;
     background-color: green;
 }
 .product3 {
     width: 200px;
     height: 520px;
     background-color: red;
 }
 .item {
    border: 10px solid rgb(255, 107, 107);
    position: relative;
 }
 .item span {
    position: absolute;
    top: -20px;
    right: -25px;
    background-color: red;
    padding: 5px;
    border-radius: 5px;
    color: white;
    z-index: 10;
 }
<div class="container">
  <div class="product1 item">
     <span>NEW</span>
     123
  </div>
  <div class="product2 item">
     <span>NEW</span>
     123
  </div>
  <div class="product3 item">
     <span>NEW</span>
     123
  </div>
 </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

Utilizing DIV elements within table cells

Within this particular table, it is not only cell B that contains both a heading and content, but cells A and C as well. My effort to establish the heading and content using DIV elements has been somewhat successful. While I have achieved the desired font ...

Can you explain the process of gathering texts based on CSS selector?

I wanted to place texts next to the div-class as shown in the following code snippets. <div class="review-contents__text">소재가 좀 저렴해 보이지만 그래도 입으면 휠씬 나아보여요</div> Initially, I wrote a code ...

Integrating external JavaScript widgets into the web application in real-time

I am currently engaged in a React js project that involves the dynamic addition of third party scripts (widgets) to the web app. These widgets encompass various third party platforms such as Twitter, Instagram, Youplay, Youtube, and more. The existing co ...

Transform spaces into %20 from an HTML input field by utilizing JavaScript or jQuery

Hi there, I'm encountering an issue with the input field on my website where users can enter search terms. I am currently extracting the user's input value and adding it to a URL string. jQuery("#searchButton").click(function(){ var simpl ...

Ensuring that the two columns in a responsive grid have equal heights is essential for maintaining a

I am currently working on a responsive website with a main content area (.content-wrapper) and a sidebar area (.search-listing). My goal is to make sure that both columns have the same height. I attempted to achieve this using the following jQuery code: j ...

What is the best method for validating multiple fields in a form with Javascript?

I am currently working on validating multiple fields within a form. Although I lack experience in JavaScript, I have managed to piece together a code that is functional for the most part. If all fields are left blank, error messages prompt correctly. Howe ...

Difficulties encountered when adjusting the size or reducing the images in a Cycle2 slideshow

Greetings to all fellow coders! Thank you for taking the time to read this post. I am currently facing a challenge in my web development project where I am trying to make my Cycle 2 slideshow images resize and reposition alongside other divs when the wind ...

JQuery .click Event doesn't center elements even with transform-origin adjustment

In the JSfiddle provided below, you can see that after a click event occurs, two span (block) elements rotate 45deg to form an "X". However, both elements are slightly shifted left, creating an off-center "X" relative to the parent's true center-origi ...

What causes the $_FILES superglobal to consistently appear empty?

Check out my page Take a look at my form: <h2>Upload Photo</h2> <form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post"> Photo <input type="file" name="image" size="30" /> & ...

Tips for showcasing cards in a horizontal inline layout

Hello everyone! I'm currently working on creating dynamic cards, but I'm having trouble displaying them inline. I'd like to arrange the cards horizontally with a scroll bar. https://i.sstatic.net/zqcua.png I want to make them display in ho ...

Guide on removing the <hr/> tag only from the final list item (li) in an Angular

This is my Angular view <li class= "riskmanagementlink" ng-repeat="link in links"> <h3> {{link.Description}} </h3> <a> {{link.Title}} </a> <hr/> </li> I need assistance with removing the hr tag for the l ...

What is the process for capturing a screenshot of a specific DOM element using Intern JS?

I'm currently utilizing intern.js for testing a web application. It allows me to run tests and generate screenshots in case of failures. My goal is to capture a screenshot of a specific element for conducting CSS regression testing with tools like res ...

Ways to create a line break within an <input> element with type="text"

https://i.stack.imgur.com/fCh87.png Is there a method to transform the Description field so that it displays as two lines instead of just one line? <label>Description</label> <input type="text" name="description" size=&q ...

Ways to widen a selected drop-down menu outside the dialog box containing it

I'm working with a Html.DropDownList that has been styled using Chosen within a jQuery UI dialog. As the list of items is quite long, when it's opened, it gets cut off by the border of the dialog window. Is there a way to extend the dropdown por ...

Discover the nodes with the highest connections in a D3 Force Graph

As I explore the functionalities of a D3 Force Directed Graph with zoom and pan features, I encounter an issue due to my limited knowledge of d3.js. Is there a way to estimate the number of links for each node in this scenario? I am currently at a loss on ...

The form embedded within the <tr> element seems to be malfunctioning

Hey there, I'm facing a little issue with my form that is nested inside a table content. It seems to not be working properly. Let me share the code snippet below: <table> <form name='editpo' method=POST action='js_buat_po.php? ...

What is the best way to execute a Java program from a PHP webpage after submitting a form?

I have a .php page where I am trying to run a Java program in the backend after submitting a form. I have attempted using exec() and system() functions, but unfortunately it is not working as expected. Can someone please provide assistance with this issue? ...

What sets apart li.parent from ul?

I am facing some confusion with this parent keyword. Are li.parent and ul the same thing? If so, can someone please explain what this means? Thank you. (nav and sidebar are classes). .sidebar ul.nav .active > a:focus, .sidebar ul.nav li.parent a.active ...

I'm looking for a method to retrieve the value of an option tag and then pass it to a helper within handlebars. Can someone

Currently, I am utilizing express and handlebars in my project. I have a specific view where I aim to display certain information based on the event when a client selects an option from a select tag. However, I have some queries regarding this: Is it fea ...

What is the method for designing a relative layout that organizes elements horizontally?

Can you tell me why elements are typically arranged vertically in a column? Is it feasible to change their orientation and display them horizontally, like in a row instead of a column? ...