Code the rubber cap using html. Page header

Create a middle part of the site header consisting of a repeating 2.gif image. To do this, make the following entry in the CSS code:
.header(background-image:url("images/2.gif");)

Now in the table row, create another cell and place the middle element of the top of the site in it, pointing to its name header in the CSS code:







Name of the site

Having created the third cell in the table row, place the right side of the site header 3.gif in this cell:










Name of the site




Sources:

  • AJAX.RU

When you create your own website, naturally you want it to display as attractively as possible, regardless of the user's browser version. In particular, to background image stretched and adjusted to the resolution of the computer monitor.

You will need

  • - skills in working with html, css, java-script.

Instructions

Open the code of your site in any editor, for example, Notepad or special program for web design, Dreamweaver. Insert the following lines into the code to stretch the . Enter Background: url (‘Insert a link to the image’).

To adjust the size of the image horizontally, use the following code: Background: url (‘Insert a link to the image’ repeat-x), vertically - at the end of the code, replace x with y. If the site style is specified in css file, paste the code into it. This way you can put a rubber background on your website.

Use the following code example, which places a background image on a page and allows it to automatically stretch to fit the resolution of the monitor on which the page is viewed. Example code: body(background: "Insert link to background image"() no-repeat fixed left center; then background-size: [...].

To stretch the background image, simply insert a picture as a background image and set its width to 100%. For example, insert the following text into the page code: background image" alt= "Enter the name of the image" width="100%" / >. Thus, the image width will be adjusted, but its proportions will be disrupted.

Similarly, you can set the image to stretch in height; instead of the width attribute, use height. Or use the following example of code for css: site background image)" > and after it add 100% width of the image, as in the previous example. You can also use the script to find out the user’s screen resolution and edit the dimensions of your table to suit it.

Video on the topic

“Rubber” is a picture that has the ability to scale. You can create such a picture using computer programs. Its convenience lies in the fact that it “stretches” in the desired direction. Such a web creation is successfully displayed in any browser. If the picture contains some useful elements, the “rubber” properties increase its functionality.

You will need

  • image, website, program Adobe Photoshop, Notepad application, HTML code, root directory of your site

Instructions

Find or create an image that you want to make scalable and post on the Internet. Run Adobe program Photoshop. Open this image in the program. Find the Slice Tool in the toolbar. Use it to cut the image into pieces. Divide it so that the entire picture consists of three graphic elements and the central one is empty. This will help the picture stretch at any monitor resolution.

Save the image optimized for web format (Save for web). When saving, set the required file format - gif, jpeg or png. In order to change individual fragments of the image, find the Slice Select Tool option in the menu and change parts of the image so that the size is minimal with the least loss of quality during rendering on the screen. After changing, save the pictures as html and images.

Often, seemingly simple layout tasks require a complex HTML markup structure and the use of CSS tricks. Centering elements or aligning content can be very tedious. One such task is aligning the elements at the top of the site so that the logo is on the left and the menu items are on the right. You can use float and position:absolute, and for vertical alignment you can add margin and padding to different elements. It seems to be nothing complicated. But if the site should be displayed correctly on mobile devices, many problems arise.

Below is a concise way to solve this problem.

The HTML markup is as simple as possible:

Super Bad

The height of the header is fixed, add text-align: justify, for child elements:

Header ( text-align: justify; letter-spacing: 1px; height: 8em; padding: 2em 10%; background: #2c3e50; color: #fff; )

Add display: inline-block for all elements nav so that you can arrange them one after another:

Header h1, header nav ( display: inline-block; )

To attribute text-align: justify worked the way we want, we need to use a little trick with pseudo-elements, which was found in the article Perfectly justified CSS grid technique using inline-block , by Jelmer de Maat:

Header::after ( content: ""; display: inline-block; width: 100%; )

The result was horizontal alignment, without using float And position:absolute. Now you need to align the elements vertically. Using vertical-align for elements nav there will be a dependence on the height of the parent block - the header. And this is not very correct. Examples of using vertical-align: top and vertical-align: middle on jsbin. Below is perhaps the most convenient method for vertical alignment.

Let's use pseudo elements again. using an example from the article Centering in the Unknown, mentioned by Michał Czernow:

Header h1 ( height: 100%; ) header h1::before ( content: ""; display: inline-block; vertical-align: middle; height: 100%; )
The result is what you need:

It remains to solve two problems: correct mapping for large quantities text in the header and adaptability. If the site title is too long, the layout will start to slide:

Using the pseudo-element trick on header:

CSS code

header ( text-align: justify; height: 15em; padding: 2em 5%; background: #2c3e50; color: #fff; ) header::after ( content: ""; display: inline-block; width: 100%; ) header > div, header nav, header div h1 ( display: inline-block; vertical-align: middle; ) header > div ( width: 50%; height: 100%; text-align: left; ) header > div: :before ( content: ""; display: inline-block; vertical-align: middle; height: 100%; )

Looks much better:

Now let's move on to adaptability. There are several ways to solve this problem; you can simply not set the height of the header, and all internal elements will be adaptive to the height. This will not require the second trick with pseudo-elements, live example on jsbin.

CSS code

header ( text-align: justify; padding: 2em 5%; background: #2c3e50; color: #fff; ) header::after ( content: ""; display: inline-block; width: 100%; ) header h1, header nav ( display: inline-block; vertical-align: middle; ) header h1 ( width: 50%; text-align: left; padding-top: 0.5em; ) header nav ( padding-top: 1em; )

If you need to set the height of the header, then you will have to use the second trick with pseudo-elements and add a media query for screens of different sizes:

@media screen and (max-width: 820px)( header ( height: auto; ) header > div, header >

The result is adaptive and looks like this on mobile devices:

In the example, 820px is used for clarity; on a live site, the value should of course be different, in accordance with the requirements. For support Internet Explorer 8 it is necessary to use “:” instead of “::” for pseudo-elements.

Final CSS code

@import url(http://fonts.googleapis.com/css?family=Lato:400,700italic); * ( padding: 0; margin: 0; ) body ( background: #1abc9c; font-family: "Lato", sans-serif; text-transform: uppercase; letter-spacing: 1px;) header ( text-align: justify ; height: 8em; padding: 2em 5%; background: #2c3e50; color: #fff; ) header::after ( content: ""; display: inline-block; width: 100%; ) header > div, header > div::before, header nav, header > div h1 ( display: inline-block; vertical-align: middle; text-align: left; ) header > div ( height: 100%; ) header > div::before ( content : ""; height: 100%; ) header > div h1 ( font-size: 3em; font-style: italic; ) header nav a ( padding: 0 0.6em; white-space: nowrap; ) header nav a:last -child ( padding-right: 0; ) @media screen and (max-width: 720px)( header ( height: auto; ) header > div, header > div h1, header nav ( height: auto; width: auto; display : block; text-align: center; ) )


Result:


In this article we will look at how to make a site header, and place the title and description of the site on it.

First of all, you need a picture for the site header. It is best done in Photoshop.

And for those who do not own this editor, I suggest the easiest way, in Paint, available on all Windows by default.

Let's make the width of the image 900px, the width of the site, and the height - 200px. Of course, you can have your own dimensions, as long as the width of the image matches the width of the site (wrapper), the height is at your discretion

As soon as the image is ready and placed in the images folder, take the one created on the previous page and proceed to install the header on the site.

In the #header selector, remove the height specified for it, and specify the width and height of the image taken.

#header (
width: 900px; - width
height: 200px; - height
background-color : #25B33f ; - background
margin-bottom: 10px; - bottom indent
}

Then we insert the image itself.

#header (
width: 900px;
height: 200px;
background-color : #25B33f ;
margin-bottom: 10px;
background-image : url(images/i8.png) - picture
}

The background-color property is indicated in case the picture suddenly, in any visitor’s browser, is not displayed.

If the picture is placed with any offset, and you need to correct it, then the property is added here

Now it’s time for the title and description of the site. To do this, write in the body tag div block with the identifier id="header" and it has two headers h1 and h3, into which we insert the name of the site and its description


Site header




Let's see what we can do.

Now, let's give the title and description a look. We create two selectors for them, and specify the following properties:

For h3 we will set the width to 200 pixels so that it does not stretch across the entire image. Indents can be manipulated depending on where in the header it will be more convenient to place the text.

Let's see the result.

In my opinion, it's very cute.

Let's summarize the code for this page.





Untitled document





Site header


How to make a header for a website with a title and description




But for me, given my age and “experience,” it was not easy
to understand precisely these nuances, they took away
most of the time.
And I decided to write my material, so that it would be easier for others
navigate the flow of new information.
All the little details that accompany the creation of a website are “chewed” here,
which other authors usually skip past.





There is another option for inserting a picture into the site header. You can insert the address of the image into the block