Section with a wavy design at the top and bottom

Looking to enhance my FAQ section with a top wave background and bottom wave background for added visual appeal.

Reference image:

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

Current progress:

HTML

<section id="faq">
  <div id="details">
  </div>
</section>

CSS

#faq{
  background-image: url("wave-top.svg")
  background-repeat: no-repeat, repeat;
  background-color: blue;
}

Background images available:

Top wave https://i.sstatic.net/mG3Vb.png

Bottom wave

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

Seeking guidance on achieving the desired result. How can I make this happen?

Answer №1

Create a unique design by using multiple backgrounds and adjusting the background-size and background-position:

.box {
  padding:11% 0; /* Adjust the padding based on the shape ratio */
  height:100px; /* Reserve space for content */
  background:
    url(https://i.sstatic.net/mG3Vb.png) top   /100% auto,
    url(https://i.sstatic.net/JSEyE.png) bottom/100% auto,
    linear-gradient(#387dff,#387dff) content-box; /* Color between shapes within content area only */
  background-repeat:no-repeat;
}
<div class="box">
</div>

Answer №2

To achieve the desired outcome, one method involves utilizing pseudo elements. Below is a snippet of code that can help get you started:

#faq {
  width: 100%;
  position: relative;
  padding: 40px 0; /* ensure padding matches height of pseudo elements */
}

#faq:before {
  content: '';
  background: url('https://i.sstatic.net/mG3Vb.png');
  width: 100%;
  height: 40px; /* set height equal to background image size */
  background-size: 100% 100%;
  position: absolute;
  top: 0;
}

#faq:after {
  content: '';
  background: url('https://i.sstatic.net/JSEyE.png');
  width: 100%;
  height: 40px; /* set height equal to background image size */
  background-size: 100% 100%;
  position: absolute;
  bottom: 0;
}

#details-wrapper {
  background-color: #387dff;
  width: 100%
}

#details {
  width: 300px;
  margin: 0 auto;
  font-family: sans-serif;
  color: white;
  font-size: 16px;
}
<section id="faq">
  <div id="details-wrapper">
    <div id="details">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
      survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularized in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </div>
</section>


Edit

Following Temani Afif's advice, I have adjusted the code snippet to use background-size: 100% 100%; instead of background-size: 100% 40px;, simplifying adjustments needed.

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

Achieve full-width centered div styling

I am facing a scenario where there are 3 divs, with the first and third div having width specified. I am looking to make the second div fill up the remaining space. Check out this Fiddle for reference: http://jsfiddle.net/YzUQy/ #div1{ height:auto; ...

Utilize class attributes inherited from a separate SCSS file

I am attempting to inherit the characteristics of a class called AClass from a file named A.scss into another file, B.scss, and make some changes to its properties based on my needs Let's assume that A.scss contains: .AClass{ border-radius: 20px; ...

Checkboxes within Angular's reactive forms are a powerful tool for creating dynamic user

Currently, I am working on a contact form that includes checkboxes for users to select multiple options, with the requirement of selecting at least one box. My challenge lies in figuring out how to pass all the selected checkboxes' data to an API usin ...

Python Issue with BeautifulSoup: find_all() returning incorrect list of elements

I am currently using Python 2.7.3 and the bs.version I have is 4.4.1 However, when running this code snippet: from bs4 import BeautifulSoup # parsing html = """ <html> <head id="Head1"><title>Title</title></head> <body&g ...

Tips for delivering a 10mb+ file that is regularly updated to the client in increments

I am dealing with a crucial 10mb+ binary file that my client needs to function properly. The problem is, every time the client visits the site, this file increases in size. Let's say the client accesses the page 20 times in one day. Since the file cha ...

Struggling to resize tables in React Material-UI

Here is my SandBox link for reference: https://codesandbox.io/embed/material-demo-j6pz9?fontsize=14&hidenavigation=1&theme=dark I am attempting to organize content within a card using an inline grid display to have them appear side by side. I unde ...

Step-by-step guide on incorporating heading and text onto an image carousel

I am facing an issue where, within an image carousel, my heading and text move down below the image instead of staying in the middle. I am utilizing the bootstrap framework. Below is the code snippet: <section> <div id="carouselExampleCo ...

Tips for utilizing the transform scale feature to expand the contents of a container while keeping the border intact

My goal is to create an animation using the transform scale property to enlarge the content of a box. However, I'm facing an issue where the border of the box also increases in size along with the content. I want only the content to change in size wit ...

PHP dropdown menu with pre-selected default value

Currently, I am immersed in a PHP project that has me solving the following challenge: if( mysql_num_rows( $result ) > 0 ) { echo '<select name="officerlist">'; while ( $rows = mysql_fetch_array ( $result ) ) { ...

Prevent Cordova from shrinking the view when focusing on an input

Currently working on developing an app using Cordova/Phonegap (v6.5.0). Platforms where I've installed the app: - IOS (issue identified) - Android (issue identified) - Browser (no issue found) I am facing a known problem without a suitabl ...

Using HTML z-index to apply filter effects

I am currently utilizing images as radio buttons, but I am encountering an issue with CSS filter effects impacting the z-index properties. Here is a sample fiddle that I have created to demonstrate the problem: https://jsfiddle.net/iambong/2kcvv3bL/1/ C ...

Failed validation for Angular file upload

I attempted to create a file validator in the front end using Angular. The validator is quite straightforward. I added a function onFileChange(event) to the file input form to extract properties from the uploaded file. I then implemented a filter - only al ...

Revising the hierarchy between !important in CSS and jQuery

(Attempting to modify CSS properties within a Chrome extension content script) Is it feasible to override CSS properties that have been marked as !important on the webpage? For example, if I aim to eliminate an important border: $(".someclass").css(&apo ...

Transfer a jQuery variable to an HTML file by utilizing the `attr` attribute

Here is my_js.js file: function updates() { $.getJSON("php/fetch.php", function(data) { $.each(data.result, function(){ $( ".mes" ).attr( "onclick","ter('this['sender_id'')"]") }); }); } And here is index.php ...

JavaScript-based Dropdown Menu Selection Without Relying on jQuery

I am currently utilizing a Bootstrap 4 navbar that includes a dropdown menu for selecting different languages. I am able to display the selected option using jQuery, but now I am seeking a way to achieve this without relying on jQuery. Below is the curren ...

The item image fails to load when Swiper is looped and using the next/prev buttons

I'm encountering an issue with swiper while trying to create a specific layout. This layout requires the first image to be larger than the others. Initially, I attempted to achieve this with a single slider but it caused miscalculations in the animati ...

Angular problem arises when attempting to map an array and selectively push objects into another array based on a specific condition

Setting up a cashier screen and needing an addToCart function seems pretty simple, right? However, I am encountering a strange logical error. When I click on an item to add it to the cart, my function checks if the item already exists in the array. If it d ...

Here is an example of how to use a script tag to check the value of a select tag in HTML:

Hi there! I'm working on a piece of code where I need to retrieve the selected value from a dropdown menu in an HTML select tag and display it in the element with the id='h1' at the bottom. The script tag is already included within the head ...

What is the process for accessing an established REST API through an HTML form?

Currently, I have set up a REST API to store data in a Mongo database through my mobile application. Now, I want to display the data from the database on a webpage. Although I already have the necessary functionality (the login request for my mobile app), ...

What is the best way to retrieve the value of a div using AutoIt?

For this particular scenario, my objective is to extract a specific value from the last div element in the following list: <div id="past"> <div class="ball ball-8" data-rollid="242539">11</div> <div class="ball ball-8" data-ro ...