Creating a Form with HTML and CSS

I am currently working on setting up a banner that includes an overlay with a cutout. Beneath the overlay, there is an image.

My goal is to create this design using HTML and CSS. I have been experimenting with pseudo-elements but I am having difficulty replicating the shape and position of the design shown below.

Below is my current HTML code:

<header class="main" style="background-image: url(./assets/images/bg-hero.jpg)">
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="row row--no-pad">
                    <div class="col-6">
                        <a href="/">
                            <img src="./assets/images/logo.png" alt="">
                        </a>
                    </div>

                    <div class="col-6">
                        <a href="#" class="menu-toggle"></a>
                    </div>
                </div>

                <div class="row">
                    <div class="banner">
                        <div class="row">
                            <div class="col-12">
                                <h1>Lorem ipsum dolor sit amet</h1>

                                <p>Lorem ipsum dolor sit amet lorem ipsum dolor sit amet, L lorem ipsum dolor sit amet.</p>

                                <a href="#" class="button button--primary">View our services</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>

This is the design I am trying to achieve:

https://i.sstatic.net/IOuRz.jpg

Thank you,

Ben

Answer №1

If you're searching for a technique called image clipping, there are numerous resources online that explain how to achieve this using CSS (here is one example). The process is quite simple and only requires a single line of CSS, utilizing the clip-path property. I recommend checking out the documentation for more information.

Creating a clip-path may be challenging depending on your desired result, but tools like Clippy can assist you with generating clip paths. For the image provided, the following code snippet should suffice:

html, body {
  margin: 0;
  height: 100%;
  background-color: #124;
  background-image: linear-gradient(to right, #111, #124);
  background-image: -webkit-linear-gradient(to right, #111, #124);
}
.background-image {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/2940219/GIF_Koi_Pond.gif');
  background-size: cover;
  background-position: center;
  clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);
}
.main-content {
  position: absolute;
  top: 0;
  left: 0;
  color: #fff;
  display: flex;
  justify-content: center;
  flex-direction: column;
  height: 100%;
  padding: 15px;
}
.main-content h1 {
  width: 250px;
  margin: 0;
}
.main-content a {
  color: #fff;
  background-color: #3a7;
  text-decoration: none;
  padding: 5px 25px;
  width: 150px;
  text-align: center;
}
<div class="background-image"></div>
<div class="main-content">
  <h1>Lorem ipsum dolor sit amet</h1>
  <p>Lorem ipsum dolor sit amet lorem ipsum dolor sit amet, L lorem ipsum dolor sit amet.</p>
  <a href="#" class="button button--primary">View our services</a>
</div>

The crucial part is:

clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);

Also, remember to include the -webkit version of the clip-path property:

clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);
-webkit-clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);

Keep in mind that applying clip-path to an element like a div will not just clip the background-image, but the entire element itself.

Answer №2

Consider using image clipping for a modern touch, or opt for a more traditional look with borders like the following example:

#cutBox{
  width: 100%;
  height: 600px;
  background-image: url('https://wallpaperplay.com/walls/full/7/2/4/272374.jpg');
  background-size: cover;
  display: flex;
}

#leftPane, #rightPane{
  background-color: midnightblue;
}

#leftPane, #rightPane{
  height: 100%;
  width: 40%;
}

#leftTri{
  border-left: 100px solid midnightBlue;
  border-top: 300px solid transparent;
  border-bottom: 300px solid transparent;
  margin-right: 200px;
}
#rightTri{
  border-left: 100px solid transparent;
  border-top: 300px solid midnightblue;
  border-bottom: 300px solid midnightblue;
}

#leftPane > .pane-text{
  position: relative;
  color: white;
  top: 40%;
  font-size: 26px;
  margin-left: 60%;
  right: -10px;
}

.subtext{
  margin-left: 20px;
  font-size: 18px;
}
<div id="cutBox">
  <div id="leftPane">
    <div class="pane-text">
      Lorem Ipsum
      <div class="subtext">
        dolor sit amet
      </div>
    </div>
  </div>
  <div id="leftTri">
  </div>
  <div id="rightTri">
  </div>
  <div id="rightPane">
  </div>
</div>

Given its responsive nature, this design may appear slightly distorted on small screens, but it generally functions well across various devices.

Answer №3

To achieve the effect shown above, you can utilize the clip-path property.

For instance, by using a polygon shape in the CSS code below, you can create a mask that forms a star shape:

.star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

If you want to learn more about the clip-path property, check out this tutorial.

Answer №4

Another technique you can utilize is layering multiple backgrounds with a gradient partially covering another background-image:

* {
  padding: 0;
  box-sizing: border-box;
}

header {
  background: linear-gradient(45deg, rgb(0, 50, 100) 60%, transparent 70%, transparent 80%, rgb(0, 50, 100) 90%) top left no-repeat, linear-gradient(135deg, rgb(0, 50, 100) 60%, transparent 70%, transparent 80%, rgb(0, 50, 100) 90%) bottom left no-repeat, url(https://placeimg.com/800/600/nature/10) center right;
  background-size: 100% 50%, auto;
  /*example purpose*/
  position: relative;
  display: flex;
  justify-content: space-around;
  flex-direction: column;
  color: white;
  max-width: 900px;
  min-height:300px;
  box-shadow: 0 0 3px;
  padding-right: 200px;
  margin: auto;
  padding-left:1em;
}

body {
  background: rgb(0, 50, 100)
}

nav {
  position: absolute;
  right: 5%;
  top: 4em;
  border-top: 2px solid white;
  border-bottom: 2px solid white;
}

nav b {
  display: block;
  width: 2.5em;
  height: 3px;
  background: white;
  margin: 6px 0
}
<header>
  <nav><b></b></nav>
  <h1>heading</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at justo eget nulla lobortis consectetur et sit amet erat. Donec ac eros nunc. Nullam euismod libero non nibh laoreet, sed sagittis purus sodales.</p>
    <a>call to action</a>
</header>

Adjust the gradient values to suit your design requirements - this code snippet serves as an illustration.

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

Craft a unique parallax effect using Framer Motion's clipping feature

To help visualize my concept, I have sketched it out using Figma. This idea involves a slide transitioning between pages. The goal is to cover the entire page with a sliding effect, and then place a sticker (dubbed the Parallax Box) on top of it. However ...

Tips for repositioning a child div to the top upon detecting a text change

I am working with a parent div that contains 3 child divs. I am curious if there is a way to automatically move a child div to the top if any changes are made to its text or link? <div id="latest"> <div class="post post-1"><a href="#"> ...

The curious conduct of wild safari creatures

I have been using JavaScript to split my ePub chapter into pages by wrapping the code with new divs that represent separate pages. I have also created CSS styles for these new divs. Everything works perfectly when the file has a filename extension of &apos ...

Incorporate Bootstrap styling into a layout featuring a row containing numerous input fields

I need some help with styling using bootstrap 5. I have set up a codepen for reference: https://codepen.io/korazy/pen/xxmWGOx Here are the issues I am facing: The input height changes to match the row height when text wraps. How can I keep the input at ...

Is the page wrapper failing to contain or wrap anything at all?

Having a bit of trouble with my div element not wrapping all the way down. To simplify things, I've applied borders and background colors to everything. Here's the HTML code... I could resort to adding a float left to the page-wrapper div as a w ...

Ways to align list items to the right and left in a stylish manner using HTML and CSS while maintaining alternating bullet points

Is there a way to create a zig-zag list where alternate list elements are right aligned while the others remain left aligned? I want it to look like this: Item1 Item2 Item3 ...

CSS - Overlapping <a> elements when resized

My buttons have the following properties: background: #c6cdf2; border: 1px solid #8896e4; border-radius: 3px; padding: 6px 10px 3px 10px; When the page resizes, the buttons don't respect the padding and start overlapping each other. https://i.sstat ...

Instructions on creating an "already clicked" style for an <a> href

Is there a solution to display my href as already clicked? I'm looking for a property or method that does not involve css or javascript. ...

Data structure designed specifically for a drawing tool application

Currently, I am in the process of developing a unique sketching application using the HTML5 Canvas element. Despite my progress, there is one particular challenge that has stumped me. The main concept of the application involves allowing users to manipula ...

Troubleshooting media queries on an example webpage

Hey there! So, I'm having a bit of trouble with running media queries on a simple HTML page. It's been a while since I worked on this stuff, and I feel like I must be doing something silly that I can't quite pinpoint. If you want to take a ...

Merge different $_GET parameters together before submitting

Not too certain if it's achievable, but here's the issue I'm struggling with. I need a form that generates this specific link. The desired end link is: I am unable to utilize a form for this task, but I can work with input fields. Any sug ...

Display Text Only When Selected - Material-UI

Is there a way to display only the selected tab's text? I came across this code snippet in the MUI documentation that involves showing labels on selection. How can I achieve this effect, maybe by manipulating the state to change the color of the selec ...

React: The row flex-direction is not being applied as expected

Although I know there are countless identical questions out there, mine lacks context and is as generic as they come. Why isn't the flex-direction row property working? React View return ( <Fragment> <h1>The About us page.</ ...

Incorporating Computer Modern Serif into Your Jekyll GitHub Page

I have customized a version of the Jekyll GitHub page from here and am trying to incorporate Computer Modern Serif font as the main body font across all pages. Following instructions from an informative answer, I have downloaded the necessary files from th ...

Having trouble identifying the source of the margin-right styling being used

I'm facing a perplexing issue with the CSS for my sidebar (#primary) on my website. Even though I haven't specified any margin for the sidebar, it is somehow getting a margin-right of 605px. In trying to solve this, I experimented with relative ...

Image link in HTML / CSS not functional on one half of the image

My webpage has an image thumbnail with accompanying text positioned to the right. I have a hyperlink on the image that should open the full-size version when clicked. However, there seems to be an issue where the hyper link only activates on the lower hal ...

Elusive Appearance of the Flask Flash Message

I have developed a web application using Flask that allows users to upload files to an S3 storage. However, I would like to enhance the user experience by showing them the progress of their file uploads in real-time. To achieve this, I am utilizing Flash t ...

Animating splitting elements with VueJS

I am facing a challenge in creating a split animation with two icons. My goal is to split the icons with some translation in the X-axis after hovering on the container, but it seems like I am missing something in my implementation. The animation does not w ...

Flexbox helps create responsive layouts with ease

Utilizing flex to centrally position my element within my layers has worked well for me, but I encountered an issue when switching to a smaller screen size. The element simply scales down in size instead of taking up the full width like it does with Bootst ...

Effortlessly apply CSS styles to multiple cached jQuery variables without redundancy

Hey there, I've got this piece of code written in Javascript for a classic ASP page. Since there are no CSS classes defined, everything is handled within the Javascript itself. var $a= $('#a'), $v= $('#v'), $s= $('#s'), ...