Issue with displaying CSS triangle (or curved square) shape in an incorrect manner

Looking to design a unique shape resembling this:

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

The shape is like a triangular form or even a rounded square (which isn't fully visible on the screen).

I attempted to use transparent borders to create it. However, the borders are not showing as transparent, hindering the shape's visibility.

.hero {
  background-color: #001d40;
  padding: 182px 0 100px 0;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}
.hero__gradient {
  width: 30vw;
  height: 100%;
  position: absolute;
  right: 0;
  top: 0;
  background: linear-gradient(-45deg, #20c0f5, #a38cff, #00c4ff, #20c0f5);
  background-size: 400% 400%;
  -webkit-animation: gradient 15s ease infinite;
  animation: gradient 15s ease infinite;
  border-bottom: solid 30px transparent;
  border-top: solid 30px transparent;
  display: inline-block;
  vertical-align: middle;
}

@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="45272a2a31363137243505706b756b7771753570717e7168">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<section class="hero">
  <div class="hero__gradient"></div>
  <div class="container">
    <div class="row">
      <div class="col-12">
        <h1>Title</h1>
      </div>
    </div>

  </div>
</section>

Tried increasing border sizes (from 30px) to 270px, the distance from the bottom of the div to triangle point. Yet, this doesn't adjust well with responsiveness.

Seems like my linear-gradient fills the space instead of being transparent?

Any suggestions for achieving this differently?

Answer №1

There are two gradients that can achieve this effect:

.box {
  height: 250px;
  background:
    linear-gradient(120deg, blue 60%,#0000 0),
    radial-gradient(100% 100% at 0 130%,blue 99%,#0000 ),
    
    /* the main background */
    linear-gradient(-45deg, #20c0f5, #a38cff, #00c4ff, #20c0f5)
}
<div class="box"></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

Modify the appearance of the post-content's color and background when hovering

I am struggling to achieve the goal of changing the background of the search box to transparent and making the search icon white on hover. Any help or suggestions would be greatly appreciated! Below is the code where I want to apply the hover CSS effect: ...

Tips for shifting text from the first column to the second column after completing the content in the first

Is there a way to continue text in the second column after filling up the first column vertically? I experimented with white space but it didn't work. Any suggestions? <!DOCTYPE html> <html lang="en"> <head> <title> ...

Hop over to another page within the same blog on Blogger with a smooth scrolling feature and automatic redirection

I am looking to enhance my blog by implementing a feature where if someone clicks on a specific link, they will jump scroll to a designated point on the same page. After a few seconds, I want them to be automatically redirected to another page within the s ...

The innerHTML property of the elements obtained using document.getElementsByClassName("") is currently malfunctioning

In my HTML file, I have a div element with the class name today. I am attempting to display the temperature on this element by using the code below. However, it seems that nothing is being printed on the div element. Can you please assist me with this is ...

What might be causing the issue with the active navigation pill's content not displaying

I'm facing an issue with Bootstrap 5 nav pills where the content of the pills is not displaying correctly. I have 3 nav pills set up, but after the 3rd pill, the content of the 3rd pill shows up in the first pill, and the content of the first pill is ...

Extract information from a constantly changing HTML webpage using Java

Is there a way to retrieve data from the Live Cyber Attack website? I am looking to extract specific information such as Time, Type of Attack, Attacking Country, and Target Country. I need this data to be dynamic for analysis purposes. Currently, I am wo ...

Is Internet Explorer freezing when appending the jQuery Library with document.write?

Similar question: Why is splitting the <script> tag necessary when using document.write()? I have this snippet of code on my webpage : var print_popup = window.open("", "Booking", "width=950,height=680, scrollbars=1") ...

The element in the data cell is a form input field

This is the content of my webpage: <input type="text" class="form-control" >id="ButonSociete"name="ButonSociete"placeholder="Societe"> <table cellpadding="0" cellspacing="0" border="0" class="display" >id="demande" width="100%"> ...

The issue with the jQuery class change not being triggered in Internet Explorer seems to be isolated, as Chrome and

This little jQuery script I have is supposed to show a fixed navigation menu once the page has been scrolled below 200px, and then change the class on each menu list item to "current" when that section reaches the top of the viewport. The issue is that th ...

An elusive error detected within a JavaScript try-catch block

Attempting to implement a simple try{}catch{} block with the following code: try{ var invoice = parseInt(localStorage[0]); if(invoice == NaN) throw "invoice not a number"; localStorage[invoice] = Ticket; console.log("localStorage["+ ...

What drawbacks come with using PHP as opposed to HTML?

Currently, I have a small number of pages published, and I am considering transitioning them from html to php. While I intend to use php more extensively in the future, I am not quite ready to fully commit to it as my primary language just yet. I underst ...

Preserving Scroll Location Through Back Button Usage and Ajax Manipulation of the Document Object Model

Currently, I am incorporating a feature where results are loaded in using ajax with an infinite scroll. However, there is an issue when a user clicks on an item in the list and navigates away from the page - upon returning by clicking the back button, they ...

HTML 5 functions properly when loaded directly as a .html file, but encounters issues when hosted on either a Django or Node

I'm having trouble getting a video to play on a webpage. Initially, I followed a standard example I found online by using the following code: <video src='video.mp4' controls></video> When I open the .html file in Safari and dou ...

Tips for identifying the correct selectedIndex with multiple select elements present on one page

How can I maintain the correct selectedIndex of an HTMLSelectElement while having multiple select elements in a loop without any IDs? I am dynamically loading forms on a webpage, each containing a select element with a list of priorities. Each priority is ...

Utilize specific CSS attributes from a class and apply them to a DOM element

It's clear that the question at hand is more complex than it initially appears. I'm not just looking for a way to apply a CSS class to a DOM element, as I'm already familiar with that (<div class="MyCssCLass"></div>) My goal is ...

Footer content encroaching on main body text

Thank you so much for your assistance. If you want to check out the content, visit it online The issue I'm facing is with my footer. It doesn't stay below the content as I'd like it to. I tried using Matthew James Taylor's technique, ...

JavaScript snippet for extracting all gif images from a website's page

I was attempting to retrieve all the images on a webpage and then print them in the console log with the following code: function findImages() { var imgs = document.getElementsByTagName("img"); var imgSrcs = []; for (var i = 0; i < ...

Getting the data from a cell by clicking on a table row

I'm attempting to retrieve the href value from the cell that has the class editlink. However, my current approach is returning undefined in the alert message. <table id="table_1"> <thead></thead> <tbody> <tr> ...

Tips on including starting information into an angularjs application from the displayed HTML

I'm currently working on a complex AngularJs application that requires User Login. Once the user is authenticated, a page will be displayed to them and additional data will be loaded later. There are two methods for achieving this: XHR Fetch af ...

`How can I find a file in Magento that contains a specific class name?`

I'm fairly new to Magento and could use some assistance with finding a specific file/template in the Magento directory. I am trying to locate the template that contains the code for the "Featured Category" section on the homepage of . I need to make s ...