Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to stretch background Picture by CSS+html+jquery

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to stretch background pictures in CSS+html+jquery. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Method 1: CSS method, this method has a defect, is to set the dead height, and is not compatible with IE.

Untitled document body {width:100%; height:700px; margin:0; url (p_w_picpaths / banner11.jpg) no-repeat; padding:0; background-size:100% 100%;);} stretch the background picture

Method 2: jquery+CSS, all compatible

Untitled document body {width:100%; height:100%; margin:0; padding:0;} $(function () {$("body") .append (""); $("# main_bg") .append ("

"); cover (); $(window) .resize (function () {/ / browser window changes cover ();}); function cover () {var win_width=$ (window). Width (); var win_height=$ (window). Height (); $(" # bigpic "). Attr ({width:win_width,height:win_height});}

Method 3: html+css, this is a dead way, hehe, but the compatibility is very good.

Untitled document body {width:100%; height:100%; margin:0; padding:0;} # main_bg,#bigpic {width:100%; height:100%;}

This is the end of the article on "how to stretch background pictures in CSS+html+jquery". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report