Div containing white CSS arrow

Is there a way to create a white arrow inside an image using only CSS, without changing any of the HTML code? Here's the snippet with the HTML:

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

.foto {
                width: 100%;
                float: left;
                min-height: 215px;
                background:
                linear-gradient(to bottom right,transparent 50%,#fff 0) bottom right/10% 50% no-repeat, linear-gradient(to bottom left,#fff 50%,transparent 0%) top right/10% 50% no-repeat, url(https://s3.pagegear.co/1/contents/blog/2016/imagen_cachorro_comprimir.jpg) center/cover
            }
<div class="foto bg_fix"><img src="https://s3.pagegear.co/1/contents/blog/2016/imagen_cachorro_comprimir.jpg" itemprop="image" width="724" height="230" style="display: none;"></div>

Answer №1

For those not needing to support Edge, using the clip-path is the simplest solution to the problem at hand. To check browser support, visit CanIUse

An incredibly useful tool for this task is Clippy. For more information on this technique, refer to MDN - CSS clip-path.

.foto {
  width: 100%;
  float: left;
  min-height: 215px;

  -webkit-clip-path: polygon(100% 0%, 85% 50%, 100% 100%, 0 100%, 0% 50%, 0 0);
  clip-path: polygon(100% 0%, 85% 50%, 100% 100%, 0 100%, 0% 50%, 0 0);
}
  /* Experiment with percentages according to your needs */

SOLUTION 2: An alternative method with better browser support is using CSS shapes.
You can create a white triangle element overlaying the image with the following code:

#triangle-left {
  width: 0;
  height: 0;
  border-top: 50px solid transparent;
  border-right: 100px solid red; /* red is just for display purposes */
  border-bottom: 50px solid transparent;
}
<div id="triangle-left"><div>

If you have both a background-image and an img tag in your HTML, choose one to use. If image cropping is a concern, consider adjusting background position or using object-fit.

Answer №2

If you want to correct your gradient, try swapping the position of the top and bottom layers. Here is how you can do it:

.foto {
    min-height: 200px;
    background:
      linear-gradient(to bottom right,transparent 49.8%,#fff 50%) bottom right/10% 50%,
      linear-gradient(to top right,transparent 49.8%,#fff 50%) top right/10% 50%,
        url("https://s3.pagegear.co/1/contents/blog/2016/imagen_cachorro_comprimir.jpg") center/cover;
     background-repeat:no-repeat;
}
<div class="foto bg_fix" ></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

Unlimited highway CSS3 motion

I have come across a stunning 2D Highway background image that I plan to use for my mobile racing game project which involves JS and CSS3. The image can be found at this link. My goal is to create an animation of the road in order to give players the illu ...

Setting up a custom PrimeNG theme to match our unique style is a great way to

I am currently using the most recent version of "primeng": "^12.2.0", and I am looking to implement my own custom theme for primeng. Despite searching through numerous blogs, I have yet to find a solution. In an attempt to create my cu ...

Scrolling through four limited list items automatically

Hey there! I am currently working on a design project. You can check it out here. I'm trying to replicate a section from another site, which you can see here. <div class="latest-winners-container"> <h3 class="header">Latest Winners< ...

Issues encountered with certain Tailwind styles functioning improperly when deployed in a production environment with Next.js

It seems that there are some style issues occurring in the production build hosted on Netlify for a specific component. The problematic component is a wrapper located at ./layout/FormLayout.tsx. Below is the code for this wrapper: const FormLayout: React.F ...

"Enjoy a full-screen background that adjusts its height while you scroll

Here is how my HTML elements are nested: body { app-root { app-block-page { app-block-content { div.wrapper { *content* } } } } } body has width:100% and ...

Position of Bootstrap glyphicon

The issue at hand I am trying to find a way to display a glyphicon icon after a text. The documentation only provides examples for displaying icons before the text, as shown here: http://getbootstrap.com/components/#glyphicons-examples <div class="gly ...

sequentially animating elements using animate css in a choreographed manner

I have created a unique jsfiddle with 20 boxes that I am trying to animate using the Animate.css plugin. The plugin can be found at daneden.me/animate. My goal is to animate each box one after the other in a sequential manner, but I seem to be having trou ...

Why does Flex-layout create odd gaps in spacing that are not present in Edge?

Trying to create a scrollable-table using flexbox. The challenge is to fit a table with fixed sizes into a viewport of specific dimensions. Here's the basic structure I have in mind: <div class="container" style="width: x; height: y; overflow ...

Tips for halting the scrolling of a div once it reaches a particular point

When I click a button, a pop-up appears. My goal is to prevent this pop-up from scrolling when it reaches the menu on my website. Here is the code snippet: <div id="dialog_box" class="dbox" style="display: none; position: fixed; right: ...

Guide to selecting all checkboxes on a website using Selenium in Python by implementing a loop

Currently, I am working on a Python program to automatically check all checkboxes on a specific webpage. Although I can successfully select a single checkbox, I am facing challenges when trying to iterate through a loop of elements that contain checkboxe ...

Arranging Page Titles in a Vertical Scroll Layout

Is there a simple way to make my page title update based on the content areas it's displayed in? I have a vertical scrolling website and I want the page title to change as users navigate through different content areas (which are located within divs ...

Alignment issue detected with the text for radio buttons

Attempting to include radio buttons on my survey form has resulted in the button and text being misaligned. Here is a screenshot showcasing how it currently looks: view image here I have experimented with using display: inline; but unfortunately, no chang ...

I need assistance from someone knowledgeable in HTML and CSS. I am trying to create a div that dynamically increases its width until it reaches a specific

Seeking assistance to create a dynamic div that continuously expands its width until it reaches a maximum of 540px. It should start at 75px. Below is the HTML and CSS code I've attempted: .Loading-Screen { background-color: black; color: alicebl ...

Is there a way to modify a jQuery animation to be positioned in the center of an element?

I have implemented a fade animation on my web page using code from JS Fiddle. Currently, the element fades in when it is fully visible in the window. Is there a way to modify this code so that the fade animation starts when only half of the element is visi ...

The AngularJS factory and controller code seem to be failing to generate any output

After running the code below, I noticed that nothing is being displayed in my console to indicate any errors. However, in listService, there is an alert within the results, but it shows as "undefined." My main goal is to have a repeat function that lists ...

I want to update the toggle switches within the GridToolbarColumnsButton component from MUI's DataGrid to checkboxes

Currently, I am developing a website where one of the pages has tabular data fetched from the backend. To filter this table, I utilized Mui filters from datagrid({...data}components={{ toolbar: CustomToolbar }}). Among these filters is a GridToolbarColumns ...

Is there a way to adjust the transparency of an image without affecting any overlaid text while using Bootstrap's carousel feature?

I am currently working with Bootstrap v4 to build a carousel featuring an image with caption text. My goal is to have the image faded while leaving the text unaffected. Despite trying several non-Bootstrap solutions, I have been unsuccessful in achieving t ...

Transitioning backgrounds in a slideshow

I am attempting to create a unique slideshow effect for my page background by changing the image URL at specific intervals with a smooth fade in and fade out transition. However, I am faced with the challenge of figuring out the best way to achieve this. ...

Content in the Bootstrap carousel vanishes without warning after a period of time

I am facing an issue with a carousel I added to a section of my website using HTML, CSS, and Bootstrap 5. The problem is that after some time, the content and the carousel inside that section disappear. Reloading the page temporarily fixes this issue but ...

Curved edges on a text box featuring a scroll bar

I'm facing an issue with my website where I have a large amount of text in an html textarea that requires a scroll bar. The problem is, I'd like to add rounded corners to the textarea, but it doesn't look good with the scroll bar. Below is ...