HTML 关于换行符?

标签 html css break word-wrap

所以,我在 Dreamweaver 中创建一个网站(类都是关于 Dreamweaver 的),但我对页面布局的最后一部分感到困惑。

目前,我的页面右上角有一个“查看购物车”按钮,按钮左侧全是空白,因此我决定在此处放置一个 768x15 的广告。但是,如果我将广告与购物车放在同一个组中,它也会向右对齐,并且恰好位于“查看购物车”的左侧。 如果我将广告放在查看购物车上方,则会换行,从而留下更多空白空间,之后也是如此。

我的简单问题:有没有办法让广告和我的“查看购物车”按钮位于同一行,而无需将广告与页面右侧对齐?

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
            <!--
                ez games
                author: kyle meek
                3/24/2013
            -->
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>ez games - home page</title>
        <link href="ez_styles.css" rel="stylesheet" type="text/css" />
        <link href="spryassets/sprymenubarhorizontal.css" rel="stylesheet" type="text/css" />
        <script src="spryassets/sprymenubar.js" type="text/javascript"></script>
    </head>

    <body id="bodyformat">
        <p id="logincart"><a href="viewcart.html">view cart</a></p>
        <script type="text/javascript">
            <!--
            google_ad_client = "ca-pub-0707070728226508";
            /* smalltop */
            google_ad_slot = "4701711529";
            google_ad_width = 728;
            google_ad_height = 15;
            //-->
        </script>
        <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
        <p id="logobanner"><img name="ez_logo" src="" width="280" height="150" alt="ez games logo" style="background-color: #ffda00" />
        <img src="" width="1000" height="150" alt="ez games banner" style="background-color: #4212af" /></p>
        <br />
        <h3 id="textalign"><a href="index.html">home</a> &dagger; <a href="about_us.html">about us</a> &dagger; <a href="games.html">games</a> &dagger; <a href="contact_us.html">contact us</a> &dagger; <a href="locate_us.html">locate us</a></h3>
        
        <div id="ad1" align="center">
            <script type="text/javascript"><!--
                google_ad_client = "ca-pub-0707070728226508";
                /* banner ad */
                google_ad_slot = "9705490722";
                google_ad_width = 468;
                google_ad_height = 60;
                //-->
            </script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
            </script>
        </div>
        <br />
        <hr />
        <span id="vertnav">
            <h2>systems</h2><hr />
            <ul>
                <li><a href="atari.html">atari</a></li>
                <li><a href="sega_genesis.html">sega genesis</a></li>
                <li><a href="ps1.html">playstation</a></li>
                <li><a href="ps2.html">playstation 2</a></li>
                <li><a href="ps3.html">playstation 3</a></li>
                <li><a href="xbox.html">x-box</a></li>
                <li><a href="xbox360.html">x-box 360</a></li>
                <li><a href="nes.html">nes</a></li>
                <li><a href="snes.html">super nes</a></li>
                <li><a href="nintendo64.html">nintendo 64</a></li>
                <li><a href="gamecube.html">gamecube</a></li>
                <li><a href="wii.html">nintendo wii</a></li>
                <li><a href="wiiu.html">nintendo wii-u</a></li>
            </ul>
        </span>
    
        <section id="sect1">
            <aside id="sides"><h1>like us on facebook!</h1><br />
                <p><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/ezgamesofficial"
                        scrolling="no" frameborder="0"
                        style="border:none; width:200px; height:80px"></iframe></p>
                <hr />
                <script type="text/javascript">
                    <!--
                    google_ad_client = "ca-pub-0707070728226508";
                    /* smallrect */
                    google_ad_slot = "5399715525";
                    google_ad_width = 180;
                    google_ad_height = 150;
                    //-->
                </script>
                <script type="text/javascript"
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
            </aside>
            <article id="art1"><h1>home</h1>
                <p>greetings! content of article one goes here! paragraphs are here. greetings! content of article one goes here! paragraphs are here. greetings! content of article one goes here! paragraphs are here. greetings! content of article one goes here! paragraphs are here. greetings! content of article one goes here! paragraphs are here. greetings! content of article one goes here! paragraphs are here.</p>
            </article>
            <article id="art2"><h1>article numero dos</h1>
                <p>lorem ipsum article 2 blah blah info. lorem ipsum article 2 blah blah info. lorem ipsum article 2 blah blah info. lorem ipsum article 2 blah blah info. lorem ipsum article 2 blah blah info. lorem ipsum article 2 blah blah info. </p>
            </article>
        </section>
        <footer id="foot"><hr />copyright&copy; ez games 2013 &dagger;&dagger;&dagger; all rights reserved.</footer>
    </body>
</html>

和我的CSS

#bodyformat #logincart {
    text-align: right;
}
#bodyformat #logincart a {
    color: #4212af;
    background-color: #ffda00;
    text-decoration: none;
    padding-left: 5px;
    padding-right: 5px;
}

最佳答案

尝试使用 float 而不是文本对齐。

#bodyformat #logincart {
    float: right;
}

更多信息: http://www.w3schools.com/cssref/pr_class_float.asp

关于HTML 关于换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15606049/

相关文章:

html - 如何让一个图像出现在另一个图像的悬停上?

html - 根据屏幕尺寸缩放div中的背景图像

javascript - 键盘不活动 x 英里秒后自动提交表单

html - 更改 bootstrap css 文件,但不工作

javascript - 跨浏览器测试工具,包括浏览器版本

css - 显示网格 <p> 行与网格 <div> 行

html - CSS:如果排在最后,则在元素之前换行

html - 基于图像的链接上的工具提示和自定义光标问题

c++ - 如何在不使用 break 的情况下退出 C++ 中的循环?

php - 防止 xdebug 在索引文件的第一行中断