如何将DIV标签的内容移到右侧

时间:2013-11-18 02:25:47

标签: html html5

我必须将div标记的内容向右移动20个像素。我怎么能这样做?

<div id="1st">
        <h1><font color="red"><i>Step - 1</i></font></h1>
        <img src="images\1.jpg" />
        <h2><font color="red"><b>Dress to impress.</b> </font></h2>
        <p>
            <font color="blue">
                <b>
                    Not only will you look and smell more attractive, taking
                    care of your<br /> grooming shows her that you're mature and capable of important
                    daily tasks. Pay<br /> particular attention to these areas:
                </b>
            </font>
        </p>
        <ul>
            <li>
                <font color="blue">
                    Shower at least once a day. It's probably best to
                    do this in the morning, so you can<br /> start the day feeling fresh and clean.
                    Wash your hair, soap up all over, and rinse<br /> off.
                </font>
            </li>
        </ul>
    </div>

2 个答案:

答案 0 :(得分:1)

在css中尝试这个

#1st { float:right; }

在你的<div id="1st></div>"之后:

<div style="clear:both;"></div>

答案 1 :(得分:1)

不确定您想要实现的目标,但这可以通过多种方式实现:

直接移动div:

#1st {
   position: relative;
   left: 20px;
}

为了给它一个移动的外观,但占用额外的20px宽度:

#1st {
   margin-left: 20px;
}

你也可以这样做(它也会移动其他内联元素):

#1st {
   margin-right: -20px;
}