Is there a straightforward method to achieve a torn border on just one side of a div block without the need for external images?
Is there a straightforward method to achieve a torn border on just one side of a div block without the need for external images?
To achieve a torn effect, you can utilize CSS background gradient:
HTML
.box:after {
content: "";
display: block;
position: relative;
top: 0;
left: 0;
width: 200px;
height: 200px;
background: linear-gradient(#2B3A48 0%, transparent 0%), linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 linear-gradient(45deg, #272220 33.33%, #2B3A48 33.33%) 0 0%;
background: -webkit-linear-gradient(#2B3A48 0%, transparent 0%), -webkit-linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 -webkit-linear-gradient(45deg, #272220 33.33%, #2B3A48 33.33%) 0 0%;
background: -o-linear-gradient(#2B3A48 0%, transparent 0%), -o-linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 -o-linear-gradient(45deg, #272220 33.33%, #2B3A48 33.33%) 0 0%;
background: -moz-linear-gradient(#2B3A48 0%, transparent 0%), -moz-linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 -moz-linear-gradient(45deg, #272220 33.33%, #2B3A48 33.33%) 0 0%;
background-repeat: repeat-x;
background-size: 0px 100%, 9px 27px, 9px 27px;
}
<div class="box"></div>
If transparency is desired, hexadecimal color values can be substituted with rgba values.
EXAMPLE
rgba(43,58,72,0.5) = 50% translucent.
To obtain the ripped effect, simply replace all occurrences of #2B3A48 with rgba(43,58,72,0.5)
.square:after {
content: "";
display: block;
position: relative;
top: 0;
left: 0;
width: 200px;
height: 200px;
background: linear-gradient(rgba(43, 58, 72, 0.5) 0%, transparent 0%), linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 linear-gradient(45deg, #272220 33.33%, rgba(43, 58, 72, 0.5) 33.33%) 0 0%;
background: -webkit-linear-gradient(rgba(43, 58, 72, 0.5) 0%, transparent 0%), -webkit-linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 -webkit-linear-gradient(45deg, #272220 33.33%, rgba(43, 58, 72, 0.5) 33.33%) 0 0%;
background: -o-linear-gradient(rgba(43, 58, 72, 0.5) 0%, transparent 0%), -o-linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 -o-linear-gradient(45deg, #272220 33.33%, rgba(43, 58, 72, 0.5) 33.33%) 0 0%;
background: -moz-linear-gradient(rgba(43, 58, 72, 0.5) 0%, transparent 0%), -moz-linear-gradient(135deg, #272220 33.33%, transparent 33.33%) 0 0%, #272220 -moz-linear-gradient(45deg, #272220 33.33%, rgba(43, 58, 72, 0.5) 33.33%) 0 0%;
background-repeat: repeat-x;
background-size: 0px 100%, 9px 27px, 9px 27px;
}
<div class="square"></div>
If a transparent black shade is desired, substitute the black color with an rgba value.
Describing the scenario, there is a container division with two floating divisions of different widths. You can view it live by following this link (look for "Hotel booking" section): I have added a border to the second division. My goal is to make this s ...
Essentially, I have a series of twitter-bootstrap square divs with classes like col-md-x, col-sm-x stacked together to form an image list. It's functioning smoothly for the most part. However, there are instances (which remain a mystery to me) where t ...
Is there a way to adjust the size of a dragged element to match its parent's dimensions after successfully dragging it (ensuring that both elements have the same width and height)? Does anyone know how to accomplish this alignment between the two ele ...
Is there a way to create a dashed horizontal line from an image and adjust the spacing between each dash using HTML and CSS? I feel like using javascript for this would be excessive. https://i.sstatic.net/YiD9q.png I'm encountering this issue with t ...
While working on the design of my website, I encountered a challenge with the sidebar. I aim to have a sidebar that hovers from the right side to the left, displaying the full content when the cursor is placed over it, much like the one featured on . Altho ...
I implemented a new feature under the Inventory > Sold individually setting using the woocommerce_product_options_sold_individually hook. Here is the code snippet: add_action( 'woocommerce_product_options_sold_individually', 'custom_produ ...
I haven't had a chance to test it on IE yet. My goal is to create a unique style for the background image and text box shape, along with borders, for the search bar on my website, [dead site]. If you check it out on Firefox or Opera and see the sear ...
I mistakenly placed the yellow dot "gif1" outside of the black box "gif" instead of inside. How many errors can you spot in my code? Take a look at the Livewave Preview to see the current state of the design. I have attempted to fix this issue by using o ...
Below is the current code snippet for my menu navigation bar: To access my live blog, please click on this link: www.4time2fun.com <div id="topmenu"> <div id="navigation"> <ul class="categories"> <li class="articles"> <a href ...
I am facing an issue with maintaining the button location when an image is added. My goal is to ensure that the button's position remains horizontal consistently. Front-end: React CSS framework: semantic-ui-react render() { return ( &l ...
I am working on a project that involves creating a list of data and using a template to draw blocks with time bars for each item in the list. The order of the items in the list can be updated at any time. However, I have noticed that whenever the list ord ...
My goal is to conceal a parent component from its child element. I attempted to achieve this by using the parent component as a background while adding additional backgrounds to the child elements for overriding purposes. However, this method did not work ...
I am using chartjs charts within bootstrap rows and columns. The number of columns per row can be dynamically changed. For example, I could rebuild my rows with the following markup: const twoColumn = spacerColumn + "<div class=&ap ...
Working with Django in the creation of a basic website, one specific page named analysis.html is utilized to access data from the Twitter API. Within the analysis.html file, there exists a card sourced from Bootstrap's components: <div class="car ...
I am attempting to incorporate stylus, a css preprocessor, with twitter bootstrap version 2.04. Upon downloading boostrap, I execute the command "stylus --css < bootstrap.css > bootstrap.styl" to generate a bootstrap.styl file. However, upon trying t ...
I am struggling with a CSS code that types out text, but it only does so once and I need it to repeat infinitely. Despite adding animation-iteration-count: infinite;, it still doesn't work as intended. Another issue is that it slows down at the end. H ...
I am facing an issue in my Laravel project where some colors are not displaying or are missing. I have tried changing the color theme without success. Additionally, the syntax highlighting is not working properly even after trying the Laravel extension. B ...
Looking for assistance with changing the order status from completed to processing. When an order is placed, it automatically goes to completed status which is not the desired outcome. The status should change based on the virtual product purchased. I wou ...
I've been experimenting with setting a personalized font for an email. Within the HTML code of the email, I included the fonts using this snippet: <head> <style> /* latin-ext */ @font-face { font-family: &ap ...
While my layout functions properly in Chrome, I am encountering an issue in IE where the main content area is displaying scrollbars instead of filling out 100% as intended. Is there a way to fix this? In the design I am working on, the main content area h ...