【问题标题】:Difficulty in getting social media icons to display inline难以让社交媒体图标内联显示
【发布时间】:2017-06-15 04:39:56
【问题描述】:

我试图让社交媒体图标显示在一条线上,而不是堆叠在一起。我尝试将显示更改为内联而不是阻塞,但所发生的只是图标尺寸变小,但仍然堆叠在一起。

代码如下:

html {
  font-size: 100%;
  /*font-size : 16px;*/
}


/*Top Header*/

.header {
  background: #e7e5e4;
}

.header_left {
  width: 65%;
  float: left;
}

.header_right {
  width: 35%;
  float: right;
  background: #e7e5e4;
}

.header_right li {
  margin-left: 45%;
  padding-top: 15px;
}

h1 {
  font-family: "Avant Garde", Avantgarde, "Century Gothic", CenturyGothic, "AppleGothic", sans-serif;
  font-size: 4.500em;
  padding: 50px 50px;
  text-align: center;
  text-transform: uppercase;
  text-rendering: optimizeLegibility;
}

.elegantshadow {
  color: #131313;
  background-color: #e7e5e4;
  letter-spacing: .15em;
  text-shadow: 1px -1px 0 #767676, -1px 2px 1px #737272, -2px 4px 1px #767474, -3px 6px 1px #787777, -4px 8px 1px #7b7a7a, -5px 10px 1px #7f7d7d, -6px 12px 1px #828181, -7px 14px 1px #868585, -8px 16px 1px #8b8a89, -9px 18px 1px #8f8e8d, -10px 20px 1px #949392, -11px 22px 1px #999897, -12px 24px 1px #9e9c9c, -13px 26px 1px #a3a1a1, -14px 28px 1px #a8a6a6, -15px 30px 1px #adabab, -16px 32px 1px #b2b1b0, -17px 34px 1px #b7b6b5, -18px 36px 1px #bcbbba, -19px 38px 1px #c1bfbf, -20px 40px 1px #c6c4c4, -21px 42px 1px #cbc9c8, -22px 44px 1px #cfcdcd, -23px 46px 1px #d4d2d1, -24px 48px 1px #d8d6d5, -25px 50px 1px #dbdad9, -26px 52px 1px #dfdddc, -27px 54px 1px #e2e0df, -28px 56px 1px #e4e3e2;
}

.header h2 {
  font-size: 24px;
  font-family: 'Niconne', cursive;
  color: #131313;
  text-align: center;
}

@font-face {
  font-family: 'si';
  src: url("../socicon/socicon.eot");
  src: url("../socicon/socicon.eot?#iefix") format('embedded-opentype'), url("../socicon/socicon.woff") format('woff'), url("../socicon/socicon.ttf") format('truetype'), url("../socicon/socicon.svg#icomoonregular") format('svg');
  font-weight: normal;
  font-style: normal;
}

@media screen and (-webkit-min-device-pixel-ratio: 0) {
  @font-face {
    font-family: si;
    src: url(../socicon/socicon.svg) format(svg);
  }
}

.header .soc {
  overflow: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
}

.header .soc li {}

.header .soc li a {
  font-family: si!important;
  font-style: normal;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -ms-box-sizing: border-box;
  -o-box-sizing: border-box;
  box-sizing: border-box;
  -o-transition: .1s;
  -ms-transition: .1s;
  -moz-transition: .1s;
  -webkit-transition: .1s;
  transition: .1s;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  overflow: hidden;
  text-decoration: none;
  text-align: center;
  display: block;
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  line-height: 40px;
  font-size: 20px;
  -webkit-border-radius: 45px;
  -moz-border-radius: 45px;
  border-radius: 45px;
  margin-right: 8%;
  color: #ffffff;
  background-color: #e7e5e4;
}

.header .soc-icon-last {
  margin: 0 !important;
}

.header .soc-twitter:before {
  content: 'a';
}

.header .soc-facebook:before {
  content: 'b';
}

.header .soc-linkedin:before {
  content: 'j';
}

.soc-email1:before {
  content: '<';
}

.header .soc a:hover {
  z-index: 2;
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
  background-color: #3371b7;
}
<!DOCTYPE HTML>
<html>

<head>
  <meta charset="UTF-8" />
  <title>Skramshots Photography</title>
  <meta name="author" content="Mark Stewart" />
  <meta name="description" content="This site is about photography by 
    Mark Stewart a.k.a. Skramshots" />
  <meta name="keywords" content="HTML, CSS, Javascript, jQuery, 
    skramshots, photography">
  <link rel="stylesheet" type="text/css" href="css/reset.css">
  <meta name="viewport" content="width=device-width, initial-
    scale=1">

  <link rel="stylesheet" type="text/css" href="css/master2.css">
  <link rel="stylesheet" type="text/css" href="css/imageeffects.css">
  <link rel="stylesheet" type="text/css" href="css/blogsports.css">
  <link rel="stylesheet" type="text/css" href="css/lightbox.css">


  <link href="https://fonts.googleapis.com/css?
    family=Niconne" rel="stylesheet">

  <link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />

</head>

<body>
  <div class="header">
    <ul class="soc">

      <div class="header_left">
        <h1 class="elegantshadow">SkramShots Photography

        </h1>
        <br>
        <h2>Move your mouse pointer over the images</h2>
        <br>

      </div>

      <div class="header_right">
        <li>
          <a class="soc-twitter" href="https://twitter.com/skramshots"></a>
        </li>
        <li>
          <a class="soc-facebook" href="https://www.facebook.com/webpage.skramshots"></a>
        </li>
        <li>
          <a class="soc-linkedin " href="https://www.linkedin.com/in/mark-stewart-8315443?trk=hp-identity-
    name"></a>
        </li>
        <li>
          <a class="soc-email1 soc-
    icon-last btn lightbox-61896367686376 email" href="https://form.jotformeu.com/61896367686376"></a>
        </li>
      </div>
    </ul>
    <br>
  </div>

</body>

</html>

我不知道如何附加我正在使用的 socicon.eot、svg、ttf 或 woff,所以我希望没有它们的代码是有意义的。

我实际上在做的是尝试为移动设备实现媒体查询以使图标显示在一行中,但我只是想让它首先正常工作`

【问题讨论】:

  • 对不起,如果我添加了多余的代码,但我正在尽力提供尽可能多的信息。

标签: html css


【解决方案1】:

首先从.header_right li 中删除margin-left: 45%;。这种风格将那些lis 推到了右边,这迫使它们堆叠起来。

然后,您只需将display:inline-block;float:left; 添加到.header_right li 选择器即可使它们显示在一行中。

【讨论】:

  • 我还要补充一点,您应该重组您的 html,以便 &lt;ul&gt;&lt;div&gt; 内,即 &lt;div&gt;&lt;ul&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
  • 好地方,我专注于 CSS。这绝对需要纠正。 @markst33 这是无序列表的正确结构:&lt;ul&gt;&lt;li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt; 可以进入&lt;li&gt;&lt;/li&gt;,但不能直接进入&lt;ul&gt;&lt;/ul&gt;。在您的情况下,但是您的开始和结束标签到处都是:)
  • 小伙子们真是太棒了,非常感谢。所以为了将它添加到媒体查询中,它只是@media screen and (max-width: 400px) { header_right li { margin-left: 1%;向左飘浮;填充顶部:15px; } }
  • 好的,当我将主 .header_right li 更改为 No margin-left 并且向左浮动时效果很好。但是,当我进行相同的更改并将它们放入媒体查询时,它就不起作用了。我希望它们以全屏宽度堆叠,但对于移动屏幕,我希望它们内联显示。所以我的媒体查询中有以下css:@media screen and (max-width: 400px) { .box { width: 100%; } .header_left { 宽度:100%; } .header_right {宽度:100%;} .header_right li { 边距右:0;向左飘浮;填充顶部:15px; padding-right: 25px;}} 我在这里做错了什么?
猜你喜欢
  • 2014-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-14
相关资源
最近更新 更多