怎么让A标签内容不换行


关键词

A标签 不换行

摘要

本文介绍在指定的宽度的div中,怎么让A标签内容不换行。

如果只对A标签使用一个“white-space: nowrap;”属性,则在火狐里面正常,在IE和Chrome里面会把所有的A标签均显示在一行,不要我们需要的样子。

.div_box{width:470px;}
.div_box a{white-space: nowrap; display:inline-block;}

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="gbk" />
    <title>New Document</title>
    <meta name="generator" content="EverEdit" />
    <meta name="author"    content="" />
    <meta name="keywords" content="" />
    <meta name="description" content=""    />
    <style>
    .div_box{width:200px;}
    .div_box a{white-space: nowrap; display:inline-block; margin-right:10px;}
    </style>
</head>
<body>
    <div class="div_box">
        <a href="">你好啊</a>
        <a href="">你好啊你好啊</a>
        <a href="">你好啊你好啊</a>
        <a href="">你好啊</a>
        <a href="">你好啊你好啊你好啊</a>
        <a href="">你好啊你好啊</a>
        <a href="">你好啊你好啊你好啊</a>
    </div>
</body>
</html>

 

要饭二维码

洪哥写文章很苦逼,如果本文对您略有帮助,可以扫描下方二维码支持洪哥!金额随意,先行谢过!大家的支持是我前进的动力!

文章的版权

本文属于“洪哥笔记”原创文章,转载请注明来源地址:怎么让A标签内容不换行:http://www.splaybow.com/post/a-how-nowrap.html

如果您在服务器运维、网络管理、网站或系统开发过程有需要提供收费服务,请加QQ:8771947!十年运维经验,帮您省钱、让您放心!
亲,如果有需要,先存起来,方便以后再看啊!加入收藏夹的话,按Ctrl+D

« 块级元素与内联元素的区别 使用jQuery来控制产品一级二级分类的弹出与隐藏 »