`

Padding Images With Absolute Position

 
阅读更多

Problems:

We want to display something like this.

The container has images on the left and right, with absolute position. The contents text is in the middle.

 

Solution:

We have an <a> as the container. A <span>for the shopping chart image and <b> for the arrow right. The html code would be:

 

                 <a href="#">
                    <span class="chart-img"></span>
                    购物车<span class="chart-item-num">0</span>件
                    <b></b>
                </a>

 

 /*leave padding on left and right for the two images. Need to set position to relative */
a {
    background: none repeat scroll 0 0 white;
    border: 1px solid #D8D8D8;
    height: 18px;
    line-height: 17px;
    width: 66px;
    padding: 0 16px 0 25px;/*WITH THE PADDING TO DISPLAY IMAGES*/
    position: relative;/*WITH THIS, THE CONTAINED IMAGE CAN USE ABSOLUTE POSITION*/
    bottom: 2px;
}

/*Use position:absolute. Display the shopping chart at (6,3) of the parent relative positioned a*/
 .chart-img {
    position: absolute;
    left: 6px;
    top: 3px;
    width: 14px;
    height: 11px;
    background: url(../images/T1CCRNXmRFXXXXXXXX.png) no-repeat -100px -21px;
}

/*A tricky method to display the arrow. Can use image too.*/
a b {
    border-color: #666666 #FFFFFF #FFFFFF;
    right:6px;
}

 

Related Patterns:

Padding Images With Background Image

 

 

  • 大小: 794 Bytes
分享到:
评论

相关推荐

    position图片定位

    position:absolute;left:20px;bottom:20px;} .bg p{display:none;width:226px;height:226px;padding:6px;background:#fff url(images/logo.gif)no-repeat 10px 10px;border:1px solid #6E939C;position:absolute;...

    pic_slide.rar

    position:absolute;top:0px;left:0px} .btn_change{width:40px;height:60px;position:absolute;text-indent:-9999px;cursor:pointer} .left_btn{background:url(../images/leftstop.jpg) no-repeat;top:85px;left:8...

    scrollbar_js实现竖向滚动条

    #dv_scroll{position:absolute;height:310px;overflow:hidden;width:570px; top:15px;} .Scroller-Container{width:100%;} #dv_scroll_bar{position:absolute;right:0;top:10px;width:14px;height:310px;border-left...

    静态网业模板1

    position:absolute; top:0px; right:0px; z-index:200; } .special_icon{ position:absolute; top:0px; _top:6px; right:2px; z-index:250; } img.thumb{ padding:10px 0 0 0; } .new_products{ clear:both; padding...

    动态爱心表白代码 html js网页源代码 情人节送女友礼物 浪漫编程 程序员表白 《点燃我温暖你》

    动态爱心表白代码 html js网页源代码 情人节送女友礼物浪漫编程,七夕程序员表白Html代码表白的套路很多,但都少不了送花送礼物,作为一个程序员,搞不懂现在流行的泡泡机、小猪、重力感应车等玩具,也不想去让朋友...

    dw google页面 源代码

    position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:...

    全屏幻灯片JQ+JS+CSS3

    #slideshow .img{position: absolute;width: 930px;height: 300px;overflow: hidden} #slideshow .img span{position: absolute;width: 19999px;display: block} #slideshow .btns{z-index: 10;position: absolute;...

    TMS Pack for FireMonkey2.3.0.1

    Fixed : Issue with absolute opacity in TTMSFMXBitmap Fixed : Issue with editing cell functionality while selecting all cells in TTMSFMXGrid v1.8.0.2 Fixed : Issue with peristing column states ...

    2018-4-25 自定义 css 样式调整块级图片标题显示位置1

    通过使用`position: absolute`和`top`, `right`, `left`属性,我们可以自由地将标题定位在图片的任意位置。同时,`padding`属性用于创建标题与图片之间的间距,而`text-decoration`属性则是用于设置标题的下划线样式...

    css层与层的重叠

    - **Absolute**(绝对定位):相对于最近的已定位祖先元素(设置了`position`属性且不是`static`)进行定位,若无已定位祖先,则相对于`&lt;body&gt;`元素。 - **Fixed**(固定定位):相对于浏览器窗口进行定位,即使页面...

    HTML 网页设计

    .pos-absolute{position:absolute;}/* Position Absolute */ .vertical-base{ vertical-align:baseline;}/* vertical align baseline */ .vertical-top{ vertical-align:top;}/* vertical align top */ .underline{ ...

    2018-4-25 自定义 css 样式调整块级图片标题显示位置 (1)1

    position: absolute; top: 0; right: 0; left: 0; border-bottom: 0; text-decoration-style: solid; text-decoration-skip: ink; text-decoration-line: underline; } ``` 2. **将标题置于图片外的右...

    HTML实例之搜索栏(附源码).docx

    position: absolute; } .btn { height: 35px; width: 35px; position: absolute; background: url("images/topbar.png") no-repeat -2px -99px; top: 6px; left: 285px; border: none; outline: none; ...

    雅虎TAB效果代码 Javascript实现

    #adsie {position:absolute; bottom:0;} /* ================================================================ This copyright notice must be untouched at all times. The original version of this ...

    最简单的JavaScript图片轮播代码(两种方法) (2).docx

    position: absolute; bottom: 20px; width: 80px; height: 20px; line-height: 20px; text-align: center; font-size: 16px; font-weight: bold; cursor: pointer; } .btn:hover { background: yellow; ...

    最简单的JavaScript图片轮播代码(两种方法).docx

    position: absolute; bottom: 20px; left: 40%; width: 80px; height: 20px; line-height: 20px; text-align: center; font-size: 16px; font-weight: bold; cursor: pointer; } #croll .ubr { position...

    web网页设计期末课程大作业:美食餐饮文化主题网站设计——中华美德6页面HTML+CSS+JavaScript

    position: absolute; bottom: 0; width: 100%; } ``` ##JavaScript交互代码 ```javascript // main.js document.addEventListener('DOMContentLoaded', function() { // 添加轮播图切换效果 var images = ...

    Jquery 通栏banner

    position: absolute; left: 0; top: 0; opacity: 0; transition: opacity 1s ease-in-out; } .slider li.active { opacity: 1; } ``` 这些样式设置了Banner容器的全屏宽度,隐藏溢出内容,并为每个Banner...

    页面图片浮动左右滑动效果的简单实现案例

    本案例中,我们将探讨如何使用CSS实现这一效果,主要涉及`background`、`display`、`margin`、`padding`、`position`等CSS属性以及动效的实现。 首先,整体布局设置: ```css html, body { height: 100%; margin...

Global site tag (gtag.js) - Google Analytics