1. 程式人生 > >border與background定位

border與background定位

預設是相對左上角定為的

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>製作我的第一個網頁</title>
        <style type="text/css">

            div{
                width:900px;
                height
:500px
; border:red solid; background-image:url(http://img.mukewang.com/52da54ed0001ecfa04120172.jpg); background-repeat:no-repeat; background-position:40px 40px; }
</style> </head> <body> <div>
</div> </body> </html>

這裡寫圖片描述

使圖片相對右邊定為

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>製作我的第一個網頁</title>
        <style type="text/css">

            div{
                width
:900px
; height:500px; border:red solid; background-image:url(http://img.mukewang.com/52da54ed0001ecfa04120172.jpg); background-repeat:no-repeat; background-position:100% 40px; border-right:50px solid transparent; }
</style> </head> <body> <div></div> </body> </html>

這裡寫圖片描述