【问题标题】:allign text and social media icons in header of webpage对齐网页标题中的文本和社交媒体图标
【发布时间】:2014-01-30 04:57:30
【问题描述】:

我正在努力将个人网站放在一起,但是我现在坚持尝试将我的社交媒体图标定位在我的标题中。请参阅下面关于我的自动取款机:

文本和 facebook 图标沿我的标题底部对齐,但是我想将文本放置在标题的中间,并且图标顶部和底部之间的空间相同,以便它出现在中心。谁能帮我这个?

谢谢

忘记加代码了,现在有点乱:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title> Chilun</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<style type="text/css">
@font-face /* support for browsers & IE v10 onwards*/
{font-family:homefont; src: url("Juice.ttf");}
{font-family:headerfont; src: url("playball.ttf");}
body {background:url('img/mybackground1.jpg') no-repeat center center fixed;}
<!-- Make Header Sticky -->
#header_container {background:#00E5EE; border:0px solid #666; height:60px; left:0; position:fixed; width:100%; top:0;}
#header{line-height:60px; margin:0 auto; width:940px; text-align:center;display:inline-block; float:right; padding:15px;}
#wrapper{width:900px;margin:0 auto;}
a{color:#444;}
.logo{margin-left:600px;margin-top:100px;background:#fff;padding:10px;}
.bigtitle{font-family: homefont; font-size:100px; color:#FF0000; text-transform:uppercase; text-align:center; margin-top:200px;}
.header{font-family: headerfont; font-size:20px; color:#FFFFFF; text-align: left; font-style:italic;}
</style>
</head>
<body>

<div id="header_container">
    <div id="header"><p class="header"> Follow me on: <a style="padding:5; margin:0; href="https://www.facebook.com/chilunliuTheBOSSE"; View my Facebook Profile</a><img src="/img/facebook-lnk.gif" width="40" height="40"></div></p>
</div>
    <div id="wrapper">
      <h1 class="bigtitle"> Chilun Liu</h1>
     </div>

</body>
</html>

【问题讨论】:

  • 在这种情况下,一张图片不是一千个单词。贴一些代码。
  • 对不起,我忘了这样做。添加代码

标签: html css


【解决方案1】:

在 css 中,选择包含图标和文本的 div(即 div.facebookicon)并为它们使用标准 css 格式(facebookicon.div {--css here--}。使用命令 text-align:center;将它们横向居中。接下来,使用填充和边距(即 padding:10px;)在垂直方向上获得所需的效果。(将其居中于页眉中间)

编辑:我注意到你使用了 text-align:left;.. 这就是为什么它被推到左边的原因。您还可以尝试以下方法:

.className{
width:300px;
height:200px;
position:absolute;
left:50%;
top:50%;
margin:-100px 0 0 -150px;
}

(具体实验)

【讨论】:

  • 谢谢大鲍勃,会调查这个。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多