简体   繁体   中英

Shift block with position: absolute

jsFiddle Demo


This shifts the CSS-code block .slide_panel left by 500px.

http://prozaik.16mb.com/misc/h1.png


I need to CSS-code shifted the unit .slide_panel left on the width of the .slide_panel

http://prozaik.16mb.com/misc/h2.png


CSS:

.wrap_news{
    position: relative;
    width: 500px;
    margin: 0 auto;
    background: cyan;
    height: 500px;
}

.wrap_news .slide_panel{
    position: absolute;
    left: -100%;
    top: 100px;
    background: red;
    padding-right: 30px;
    border: 1px solid #000; 
}

.wrap_news .slide_panel.showPanel{
    left: 0;
}

You need to set the right property to 100%, so it will be pushed just outside the left boundary:

right: 100%;

http://jsfiddle.net/Hptdb/2/

you can make

right: 100%;

and you can use table if you new in css

<table align="center" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" width="50%" align="right">left</td>
<td valign="top" width="50%">right</td>
</tr>
</table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM