网页 | FontAwesome 跨度在 h1 中创建换行符

标签 html css

我试图在我的 h1 文本之前创建一个图标,但随后发生了这种情况: ScreenShot

我的 CSS 是:

@font-face {
  font-family: 'Titillium Web';
  font-style: normal;
  font-weight: 300;
  src: local('Titillium WebLight'), local('TitilliumWeb-Light'), url('../fonts/Titillium.woff') format('woff');
  unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Titillium Web';
  font-style: normal;
  font-weight: 300;
  src: local('Titillium WebLight'), local('TitilliumWeb-Light'), url('../fonts/Titillium.woff') format('woff');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215;
}
@font-face {
  font-family: 'Titillium Web';
  font-style: normal;
  font-weight: 300;
  src: local('Titillium WebLight'), local('TitilliumWeb-Light'), url('../fonts/Titillium.woff') format('woff');
}
.settings {
  height: 73px;
  float: left;
  width: 250px;
  margin: 0px;
  text-align: center;
  font-size: 20px;
  font-family: 'Strait', sans-serif;
}
.scrollbar {
  height: 90%;
  width: 100%;
  overflow-y: hidden;
  overflow-x: hidden;
}
.scrollbar:hover {
  height: 100%;
  width: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
}
#style-1::-webkit-scrollbar-track {
  border-radius: 2px;
}
#style-1::-webkit-scrollbar {
  width: 5px;
  background-color: #F7F7F7;
}
#style-1::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  background-color: #BFBFBF;
}
.fa-lg {
  font-size: 1em;
}
.fa {
  position: relative;
  display: table-cell;
  width: 55px;
  height: 36px;
  text-align: center;
  top: 12px;
  font-size: 20px;
}
.main-menu:hover,
nav.main-menu.expanded {
  width: 250px;
  overflow: hidden;
  opacity: 1;
}
.main-menu {
  background: #F7F7F7;
  position: absolute;
  top: 0;
  bottom: 0;
  height: 600px;
  left: 0;
  width: 55px;
  overflow: hidden;
  -webkit-transition: width .2s linear;
  transition: width .2s linear;
  -webkit-transform: translateZ(0) scale(1, 1);
  box-shadow: 1px 0 15px rgba(0, 0, 0, 0.07);
  opacity: 1;
}
.main-menu > ul {
  margin: 7px 0;
}
.main-menu li {
  position: relative;
  display: block;
  width: 250px;
}
.main-menu li > a {
  position: relative;
  width: 255px;
  display: table;
  border-collapse: collapse;
  border-spacing: 0;
  color: #8a8a8a;
  font-size: 13px;
  text-decoration: none;
  -webkit-transform: translateZ(0) scale(1, 1);
  -webkit-transition: all .14s linear;
  transition: all .14s linear;
  font-family: 'Strait', sans-serif;
  border-top: 1px solid #f2f2f2;
  text-shadow: 1px 1px 1px  #fff;
}
.main-menu .nav-icon {
  position: relative;
  display: table-cell;
  width: 55px;
  height: 36px;
  text-align: center;
  vertical-align: middle;
  font-size: 18px;
}
.main-menu .nav-text {
  position: relative;
  display: table-cell;
  vertical-align: middle;
  width: 190px;
  font-family: 'Titillium Web', sans-serif;
}
.main-menu .fb-like {
  left: 180px;
  position: absolute;
  top: 15px;
}
.main-menu > ul.logout {
  position: absolute;
  left: 0;
  bottom: 0;
}
.no-touch .scrollable.hover {
  overflow-y: hidden;
}
.no-touch .scrollable.hover:hover {
  overflow-y: auto;
  overflow: visible;
}
.settings:hover,
.settings:focus {
  background: url(http://s17.postimg.org/74cl7s05b/logo_hover.jpg);
  -webkit-transition: all 0.2s ease-in-out, width 0, height 0, top 0, left 0;
  -moz-transition: all 0.2s ease-in-out, width 0, height 0, top 0, left 0;
  -o-transition: all 0.2s ease-in-out, width 0, height 0, top 0, left 0;
  transition: all 0.2s ease-in-out, width 0, height 0, top 0, left 0;
}
.settings:active,
.settings:focus {
  background: url(http://s3.postimg.org/bqfooag4z/startific.jpg);
  -webkit-transition: all 0.1s ease-in-out, width 0, height 0, top 0, left 0;
  -moz-transition: all 0.1s ease-in-out, width 0, height 0, top 0, left 0;
  -o-transition: all 0.1s ease-in-out, width 0, height 0, top 0, left 0;
  transition: all 0.1s ease-in-out, width 0, height 0, top 0, left 0;
}
a:hover,
a:focus {
  text-decoration: none;
  border-left: 0px solid #F7F7F7;
}
nav {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
}
nav ul,
nav li {
  outline: 0;
  margin: 0;
  padding: 0;
  text-transform: uppercase;
}
.darkerli {
  background-color: #ededed;
  text-transform: capitalize;
}
.darkerlishadow {
  background-color: #ededed;
  text-transform: capitalize;
  -webkit-box-shadow: inset 0px 5px 5px -4px rgba(50, 50, 50, 0.55);
  -moz-box-shadow: inset 0px 5px 5px -4px rgba(50, 50, 50, 0.55);
  box-shadow: inset 0px 5px 5px -4px rgba(50, 50, 50, 0.55);
}
.darkerlishadowdown {
  background-color: #ededed;
  text-transform: capitalize;
  -webkit-box-shadow: inset 0px -4px 5px -4px rgba(50, 50, 50, 0.55);
  -moz-box-shadow: inset 0px -4px 5px -4px rgba(50, 50, 50, 0.55);
  box-shadow: inset 0px -4px 5px -4px rgba(50, 50, 50, 0.55);
}
.main-menu li:hover > a,
nav.main-menu li.active > a,
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus,
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus,
.no-touch .dashboard-page nav.dashboard-menu ul li:hover a,
.dashboard-page nav.dashboard-menu ul li.active a {
  color: #fff;
  background-color: #00bbbb;
  text-shadow: 0px 0px 0px;
}
.area {
  float: left;
  background: #e2e2e2;
  width: 100%;
  height: 100%;
}
.content {
  height: 100%;
  width: 745px;
  overflow-y: scroll;
  overflow-x: scroll;
  word-wrap: break-word;
  position: absolute;
  top: 0px;
  left: 55px;
  background: #17191c;
}
.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
  width: 100%;
  font-family: 'Titillium Web', sans-serif;
  border-left: 3px solid;
  color: #abb0ba;
  font-size: 22px;
  margin-left: 20px;
  padding-left: 10px;
}
.content h1 span,
.content h2 span,
.content h3 span,
.content h4 span,
.content h5 span,
.content h6 span {
  display: inline;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">

<div class="content">
  <h1>
    <span class="fa fa-music"></span>
    Music
  </h1>
</div>
<nav class="main-menu">
  <div class="scrollbar" id="style-1">
    <ul>
      <li>
        <a to="home">
          <span class="fa fa-home fa-lg"></span>
          <span class="nav-text">Home</span>
        </a>
      </li>
      <li>
        <a to="settings">
          <span class="fa fa-cog fa-lg"></span>
          <span class="nav-text">Settings</span>
        </a>
      </li>
      <li class="active">
        <a to="music">
          <span class="fa fa-music fa-lg"></span>
          <span class=nav-text>Music</span>
        </a>
      </li>
    </ul>
  </div>
</nav>

如何使图标与文本内嵌?

最佳答案

在您的 CSS 中更改以下类

 .fa {top:12px} 

  .fa {top:0} 

关于网页 | FontAwesome 跨度在 h1 中创建换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42371685/

相关文章:

javascript - Bootstrap 导航菜单不适用于移动 View

css - 在 javafx 中创建类似 opera 的选项卡

css - 我意识到特定操作系统的浏览器测试是必要的,但是特定操作系统的版本呢?

html - localStorage、sessionStorage、session 和 cookie 有什么区别?

javascript - 使用jquery创建元素时出错

java - 关闭点击不起作用

html - 如何在 CSS/HTML 中为任意内容定义一个矩形框?

html - Chrome 不再显示文本

html - 仅将 CSS 样式应用于嵌套列表根中的第一个 <li>

html - 输入场效应