繁体   English   中英

如何放置 <p> 元素之后的<a>元素,而无需将其放在新行上</a>

[英]How to put an <p> element directly after an <a> element without placing it on a new line

当我在自己的网站上工作时,我遇到了一个问题。 我想在<.a>元素之后直接放置<.p>元素,因此它下没有一行。

现在如何:

Login 
\
Register

我要的是:

Login \
Register

如果您想看一下,可以访问我的网站:

v14rkoende.helenparkhurst.net

这是我的html代码:

<div class=logreg>

        <div class=logregb>

            <p class=loginl ><a href=login.html class=loginr>Login</a> /</p>
            <p class=loginl ><a href=register.html class=loginr>Registreer</a></p>

        </div>

    </div>

这是我的CSS代码:

.loginr {
    font-family: Century Gothic;
    color: white; 
    font-size: 12px;
    margin-bottom: 0px;
    margin-top: 0px;
    text-decoration: underline;
}

.loginl {
    font-family: Century Gothic;
    color: white; 
    font-size: 12px;
    text-decoration: none;
    margin: 0px;
}

.logreg {
    margin-left:-20px;
}

.logregb {
    width: 0px;
    margin-left: auto ;
    margin-right: auto ;
    margin-top: -40px;
}

谢谢你的协助


解决方案是使宽度更大,例如:

 .logregb {
    width: 100px;
    margin-left: auto ;
    margin-right: auto ;
    margin-top: -40px;
}

感谢所有人的快速遮阳篷!

试试这个(未测试)

.loginl a {
 float:left;
}

您的父DOM元素的宽度很小。 删除.logregb {width: 0px;}因为它会导致2个换行符。

或者

nowrap添加到CSS如下:

.loginl {
    [...]
    white-space: nowrap;
}

这是JSFiddle: http : //jsfiddle.net/j3t47pqg/1/

 pa { display:inline-block; } 
 <div class=logreg> <div class=logregb> <p class=loginl > <a href=login.html class=loginr>Login</a> <a href=register.html class=loginr>Registreer</a> </p> </div> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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