使用CSS将DIV向右下方浮动

Si8*_*Si8 10 html css

我有三个DIV,在DIV中,我想将"了解更多"浮动到右下方,这样它就会在灰色背景之上.

三个div

CSS

/* the div for LEARN MORE */
#trt {
    z-index: 9999999999999;
    position: relative;
    float: right;
    bottom: 0; // not working
    top: 12; //not working
}

/* the entire div */
.main .cols { padding-left: 2px; padding-right: 0px; padding-top: 10px; }
.main .cols .col { width: 315px; height: 108px; float: left;  background: url(images/tempf.png) no-repeat 0 0; }
.main .cols .col:after { content:''; width: 100%; clear: both; }
.main .cols .col + .col { padding-left: 20px; }
.main .cols .col img.hid { float: left; width: 129px; height: 108px;  }
.main .cols .col-cnt { width: 183px; float: right; }
.main .cols .col .more { font-weight: bold; color: #0206AA; }
Run Code Online (Sandbox Code Playgroud)

HTML

<div class="main">              
    <section class="cols">
        <div class="col">
            <a href="link.aspx">
                <img class="hid" src="css/images/orgNews.png" alt="" />
            </a>
            <div class="col-cnt">
                <h3 style="color: #FFFFFF;">Organization News</h3>
                <p style="color: #FFFFFF;">Interfaith Medical Center related news and updates</p>
                <div id="trt">
                    <img src="css/images/arrow.png" width=11 height=11 align=absmiddle />
                    <a href="link.asp" class="more">Learn More</a>
                </div>
            </div>
        </div>
    </section>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS - 编辑后

.trt {
    z-index: 9999999999999;
    position: absolute;
    bottom: 3px;
    right: 3px;
}
...
.main .cols .col-cnt { width: 183px; float: right; position: relative; }
...
Run Code Online (Sandbox Code Playgroud)

编辑后

这个CSS工作:

.trt {
    z-index: 9999999999999;
    position: absolute;
    top: 85px;
    right: 3px;
}
Run Code Online (Sandbox Code Playgroud)

kin*_*ode 9

设置col-cntdiv position: relative设置trtposition: absolute; bottom:3px; right:3px;应该让你到达你需要的地方..也trt应该是一个类,如果它被重用


sea*_*g9x 6

首先,您必须将#trt 的parent 设置为relative。

#parent-of-trt  {
   position: relative;
}
Run Code Online (Sandbox Code Playgroud)

并将 #trt 设置为绝对

#trt {
   position: absolute;
   left: 4px;
   bottom: 5px;
}
Run Code Online (Sandbox Code Playgroud)