HTML displays text on the Image

Source: Internet
Author: User

Example:

The first method is to use the image as the background image, that is, background-image: URL (".......");

You can control the horizontal and vertical Tile of the background image here:

Background-repeat: none; Do not tile

Background-repeat: Repeat-X; horizontal X axis tiled

Background-repeat: Repeat-y; horizontal Y axis tiled

Background-repeat: Repeat; the horizontal and vertical y axes are tiled, which is also the default status.

 

The second method is to place the IMG block and text block in the same Div, and then set the position between them, for exampleCodeBlock:

<Div style = "position: relative;">

<Div style = "position: absolute; Z-index: 2; left: 10px; top: 10px">

Haha

</Div>

</Div>

Fine-tune the remaining locations based on actual conditions ~~

 

Differences between relative and absolute attribute values in position:

Position: absolute. This is absolute positioning;
Is relative to the browser positioning.
For example, position: absolute; left: 20px; top: 80px; the container is always located at the position 20px left of the browser and 80 PX away from the browser.

Position: relative is relative positioning, which is relative to the previous container positioning. In this case, the top left cannot be used for positioning. Margin should be used.

For example: <Div class = "1"> </div> <Div class = "2"> </div>

When 1 is fixed. 1 style float: Left; width: 100px; Height: 800px;
The Style 2 is float: Left; position: relative; margin-left: 20px; width: 50px;
2 is located at the right of 1, PX away

 

More please see: http://net08118.blog.163.com/blog/static/11011170420129193741264/

Http://blog.csdn.net/chhuma/article/details/7484940

 

To limit the maximum width and height of an IMG tag, use the max-width and max-height attributes. The code below:

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.