div中的文本自动转到底部

问题描述 投票:2回答:5

我的文字位于div的底部,但它需要位于div的顶部。

Picture of the issue.

我的CSS代码:

#pagetitle
{
    float: left;
    width: 472px;
    height: 109px;
    font-size: 80px;
    font-family: 'CodePro';
    padding: 0px;
    margin: 0px;
}

html, body{
    margin:0 !important;
    padding:0 !important;
    opacity: 0.99;

    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;

    background-color: #cfcfcf;
}

现场预览在link

css html
5个回答
2
投票

试试这个:

#pagetitle
{
    line-height: 23px; /* or so, it depends on your need*/
}

1
投票

它似乎与你正在使用的字体系列(CodePro)有一些关系,如果你将字体系列更改为Helvetica,你会看到你期望的效果。您可以通过几种不同的方式调整文本的位置。

margin-top: -30px;

要么

line-height: 40px;

到#pagetitle,仅举几例。


0
投票

它是字体的字体和大小。你可以给它一些负余量或一些线高。

#pagetitle {
   margin-top: -30px;
}

0
投票

将此添加到您的CSS:

#pagetitle
{
    line-height: 10px;
} 

0
投票

如果它的问题是使用l​​ine-height属性。我一直觉得安全...

position:relative;
top:-20px;

#pagetitle
    {
        float: left;
        width: 472px;
        height: 109px;
        font-size: 80px;
        font-family: 'CodePro';
        padding: 0px;
        margin: 0px;
        position:relative;
        top:-20px;
    }

top:-20px一起玩,以获得理想的结果。

© www.soinside.com 2019 - 2024. All rights reserved.