How HTML adds content (such as text, menu bars, buttons, etc.) to a picture __html

Source: Internet
Author: User
How HTML adds content to a picture

Demo effect

One of the most recent effects is that the page has a big picture on the head, and the menu bar floats over the picture. I see the Internet is very simple, the general principle is that the picture is defined as relative positioning, the text is defined as absolute positioning can be. But I didn't do well and it took me hours to get the menu bar floating in the picture. Here is the effect chart. first of all, Cloth Bureau:

Notice that the menu bar and text are not above the picture, and the background color I set for the menu bar is translucent black, which, if it floats successfully on top of the picture, is translucent.

Now for pictures and text boxes. IMGW Add position attributes: Position:relative (relative positioning)

The box for the text. Words add: position:absolute; (absolute positioning)

Also add to menu bar nav: Position:absolute (absolute positioning)

These three positions are important.

This effect is as follows:

After positioning, you can see the menu bar is gone, the text is not floating in the picture. Don't worry, the menu bar is just covered, now set z-index:10 for the menu bar,

The text sets the distance top:50% for it, the distance left:30%.

Here is the complete code:

<! DOCTYPE html>  



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.