The header matched to the fullscreen

The header matched to the fullscreen

How to prepare a the header matched to the fullscreen? There are many solutions for this task and much better or worse end effects. Each that satisfies the assumptions of the author, it may be sufficient. The following entry shows how to create a container <div>, the size of any browser window on your computer, tablet or smartphone. By placing such a container as the first under the <body> tag has the effect of a full window after the page is opened. As a background, you can use an image, video or gif, and in the foreground put menu. An important element of this solution is that the background will be matched to the window, cutting off its extreme parts, and the container <div> will move in its entirety. An example of such a solution is a page PerfectSoft or relaksowanie.pl.

Needed elements of code

The whole consists of small blocks of code, which for clarity will be provided in separate files. The first will be presented html code that attaches files css and javascript, and in the body section shows the container header (“large-header”) and the container text in the rest of the page (“outside_header”). Starting file “demo.js” must be found for container “large-header” because it was there defined function and its call. This allows you to run it as soon after the formation of the container, but it can be changed freely, without compromising the functionality of the code.

 

In the file “style.css”, the most important is to put the record “margin: 0;” for the body tag. Apart from this entry will not be possible to achieve full-screen, as will be included by default margins. It is also appropriate to extend this record of other tags that should not have margins or frames. An example of file write:

 

File “component.css” was prepared for the determination of the container header (“large-header”).

 

The last file is “demo.js.” It’s the function is called regulating the size of the container header (“large-header”).

The first stores in the variable height of the window, because the width of the match thanks to an entry in the css (“width: 100%;”). For this purpose is the “innerHeight” which has the width of the window without the various types of sliders and other features – inner window itself. In the present case, this is crucial, because the field “Height” – giving the full width of the window, there would check on some devices.
Then the variable “largeHeader” is assigned to the container by its id and using the properties assigned is obtained before the window width.

Loading Facebook Comments ...

Leave a Reply

Or