Covering the TD Cell with an Image Stretch
Issue: Enhance a webpage by stretching a background image to fill the entirety of a table cell (
CSS Fragment:
<code class="css"><style> .style1 { background-image: url('http://localhost/msite/images/12.PNG'); background-repeat: no-repeat; background-position: left center; } </style></code>
Objective: Employ CSS to extend the background image to encompass the entire TD cell, achieving a "stretched" effect.
Solution:
<code class="css">.style1 { background: url(images/bg.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }</code>
Compatibility:
Additional Option for IE:
<code class="css">filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='.myBackground.jpg', sizingMethod='scale'); -ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='myBackground.jpg', sizingMethod='scale')"; zoom: 1;</code>
Acknowledgement:
Credits go to Chris Coyier for the insightful article found at: http://css-tricks.com/perfect-full-page-background-image/
The above is the detailed content of How to Stretch a Background Image to Fill a TD Cell with CSS?. For more information, please follow other related articles on the PHP Chinese website!