Repeat Top Background

I am currently in the process of converting this design into HTML & CSS code.

I am facing a challenge when it comes to repeating the background on the top section since the left and right parts do not use the same image file.

Even after attempting to use this technique, I was unable to achieve the desired result.

My goal is to repeat these images and have the header in the middle (header.jpg):

I also experimented with background-position, but unfortunately, it did not solve the issue.

Any suggestions from my fellow developers?

Thank you for your help.

Answer №1

Are you looking for help on implementing a specific layout? If so, here's an example that might be what you need:
http://jsfiddle.net/ub66M/1/

Here is a snippet of the HTML code:

<div id="page">
  <div id="header-wrapper">
    <div id="header-left"><!-- empty, just for background --></div>
    <div id="header-right"><!-- empty, just for background --></div>
    <div id="header-center">
        the actual content of the header comes here
    </div>
  </div>
</div>

And this is how the CSS looks like:

#header-wrapper {
    width: 100%;
    position: relative;
}
#header-left, #header-right {
    width: 50%;
    position: absolute;
    top: 0;
    background-repeat: repeat-x;
    height: 284px;
    z-index: -1;
}
#header-left {
  left: 0;
  background-image: url(http://i.imgur.com/tcr1F.jpg);
}
#header-right {
  left: 50%; 
  background-image: url(http://i.imgur.com/PchTG.jpg);
}
#header-center {
    width: 500px; /* adapt to actual width of center slice */
    height: 284px;
    margin: 0 auto;
    background: url(http://placehold.it/500x284) no-repeat; /* put your center slice here */
}

To achieve this layout, you need to add two extra divs positioned behind the header content. Make sure the center div contains the correct image slice and the actual header content.

I hope this explanation is clear and helps you with your query!

Answer №2

Maybe it would be more effective to duplicate the background and make it the background of the wrapping <div class="wrapper"> that contains all the website content, or a similar approach... and make a bigger cut, not just 1 pixel in height, but around 50-60 pixels

Answer №3

In creating this design, my approach would involve extracting a horizontal portion (approximately 15-20 pixels) from the gradient background transitioning from pink to orange. I would then set this section to repeat vertically on the <body> element. The pink borders framing the main content seem to serve the purpose of defining the top and bottom boundaries, adding a subtle touch of color to the overall layout.

Answer №4

The header cannot be accurately depicted with the two images provided as the gradient is neither horizontal nor vertical, but diagonal. To achieve this effect, CSS gradients can be used easily.

http://jsfiddle.net/ZteRf/

background: -moz-linear-gradient(-45deg, #ff3232 0%, #fff989 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,#ff3232), color-stop(100%,#fff989)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, #ff3232 0%,#fff989 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, #ff3232 0%,#fff989 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, #ff3232 0%,#fff989 100%); /* IE10+ */
background: linear-gradient(135deg, #ff3232 0%,#fff989 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff3232', endColorstr='#fff989',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */

Answer №5

Make sure to add this snippet to your CSS file

   body
   {
   background-image:url("http://example.com/background.jpg");
   background-repeat:repeat-y;
   }

For a live demonstration, visit http://example.com/demo (Drag the slider between javascript and result to see the full image)

Best of luck! :)

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

Has anybody dabbled with Indexed DB before?

After finding out that WebSQL is deprecated, I started exploring IndexedDB as an option for browser offline storage. However, I discovered that IndexedDB has undergone significant design changes since the examples provided in HTML5Rocks (http://www.html5 ...

Show and hide the div by clicking a button

Looking at the image below, my goal is to display the div under the reply button. (The div consists of a text box and send button) https://i.stack.imgur.com/jnaV4.png The code I have currently functions correctly. However, when clicking any reply button ...

What methods can users employ to effectively manage and maintain their in-app purchases using my application?

Hey there, I could really use some assistance. Recently, I created a mobile app for a client that allows users to purchase and watch video courses. However, I'm facing an issue where when a user buys a course and then refreshes the app, they are redir ...

Locating items based on checkboxes and dropdown selection

My goal is to calculate the sum of certain numbers based on checkboxes and a select option. Below is the code I am using: <div class="container"> <select> <option value="1">1</option> <option value="2">2</option> <o ...

What is the best way to ensure that a div containing lengthy text wraps to the next line as if it were only text overflow?

Is there a way to make a div or span within another div act as text, causing overflow to shift to the next line? I'm unsure of which CSS properties would achieve this effect. I've attempted using overflow-wrap: break-word; word-break: break-al ...

The jQuery scripts are having trouble cooperating

Currently, I am in the process of developing a website. The main focus at the moment is on creating a responsive menu and incorporating jQuery scripts. However, I seem to be facing some challenges in getting everything to work seamlessly together. Each scr ...

Issue with aligning CSS in Internet Explorer 7

Everything looks great on Firefox and IE8, but on IE 7 the middle "search input text field" is not aligned properly with the other two fields. It seems to be dropping down slightly. Here is the code - thank you for your help: <!DOCTYPE html PUBLIC "-/ ...

Unusual css glitch observed when hovering over a span/link

Currently, I'm struggling with a CSS code issue. My goal is to have the div #hidden show when someone hovers over the link in #trigger. <!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> ...

Adjusting Screen Size for Lottie Animation in React.js

I need assistance with resizing a lottie animation component on my website's landing page to set its display to none on mobile devices. How can I achieve this? See the lottie component code below: import React from "react"; import Lottie fr ...

The image in drag and drop ghost preview is not appearing on Firefox

I want to show a ghost element instead of the default browser preview while dragging and dropping. However, in Firefox, the image inside the ghost element is not displayed during dragging. Oddly enough, if I drop it and then drag again, the image does appe ...

Tips for pressing the enter key to submit when faced with two buttons

I am developing a form with two input fields and their respective submit buttons. I want users to be able to enter text into either field, hit the Enter key, and have it trigger the same action as clicking the submit button. Currently, pressing Enter after ...

Adjusting Column Placement in Bootstrap Grid System

I am struggling to achieve a specific bootstrap grid system and could use some guidance. Here is the grid system I am trying to create: https://i.sstatic.net/fhEHU.jpg I have attempted to implement the grid system using the code provided in this JSFiddl ...

Automated scrolling effect within a container element

I am working on a div container named wrapper2 that houses a chat interface. Inside the container, there are five messages in a div called chatleft, each containing images. The height of the wrapper2 div is smaller than the combined height of all the messa ...

Could Google Adsense be causing issues with my website's navigation bar?

There seems to be an irritating bug that I've come across. While navigating my website, [the menu (located in the top right corner) functions correctly]. However, when you land on a page with a Google AdSense ad, the menu suddenly appears distorted ...

Show a PDF document on the webpage by making an ajax request in a C# MVC application

Using ItextSharp, I am creating a Pdf from html and trying to show a preview of the Pdf on the screen for the user to interact with. Although the Pdf generation is correct, I am struggling to display it on the screen. Here is the Ajax call: function Pre ...

Adjusting the spacing between characters in SVG text elements

Take a look at this unique SVG: <svg xmlns="http://www.w3.org/2000/svg"> <defs> <style type="text/css"><![CDATA[ .code { font-family: monospace; white-space: pre; tab-size: 4; } ]]></style> </defs> <text class="cod ...

My divs are multiplying twice as fast with every iteration of the Javascript For Loop

Recently, I developed a script that generates a series of fields based on a number provided by the user (k). Initially, I had a script that would create the correct number of fields. However, I decided to arrange them like vectors on the screen, so I made ...

What methods can I use to minimize the gap between images within the <figure> element?

    Is there a way to adjust the spacing between images when using <figure>? I've been trying to reduce the space, but I can't seem to make it work. I want to display 3 images side by side in one row, but because I'm struggling to ...

Selecting a filter for an array of objects

I'm struggling to implement a search feature in my mat-select DropDown. The existing options I've found online aren't quite working for me due to the object array I am passing to the Dropdown. Any assistance or guidance on this matter would ...

Having difficulty changing the background color to black for the parent div that houses multiple child divs

Here is an example without the height attribute provided: http://jsfiddle.net/karthik64/pFcpX/ And here it is with the height attribute included: http://jsfiddle.net/karthik64/pFcpX/1/ The issue arises when I try to set a fixed 'height' attribu ...