背景显示不正确

时间:2017-12-07 21:12:01

标签: html css

对于我的登录表单,我添加了按钮登录Facebook和谷歌。

基本上,从codepen复制/粘贴。 HTML:

<button class="loginBtn loginBtn--facebook">   Login with Facebook </button>

<button class="loginBtn loginBtn--google">   Login with Google </button>

CSS:

body { padding: 2em; }


/* Shared */
.loginBtn {
  box-sizing: border-box;
  position: relative;
  /* width: 13em;  - apply for fixed size */
  margin: 0.2em;
  padding: 0 15px 0 46px;
  border: none;
  text-align: left;
  line-height: 34px;
  white-space: nowrap;
  border-radius: 0.2em;
  font-size: 16px;
  color: #FFF;
}
.loginBtn:before {
  content: "";
  box-sizing: border-box;
  position: absolute;
  top: 0;
  left: 0;
  width: 34px;
  height: 100%;
}
.loginBtn:focus {
  outline: none;
}
.loginBtn:active {
  box-shadow: inset 0 0 0 32px rgba(0,0,0,0.1);
}


/* Facebook */
.loginBtn--facebook {
  background-color: #4C69BA;
  background-image: linear-gradient(#4C69BA, #3B55A0);
  /*font-family: "Helvetica neue", Helvetica Neue, Helvetica, Arial, sans-serif;*/
  text-shadow: 0 -1px 0 #354C8C;
}
.loginBtn--facebook:before {
  border-right: #364e92 1px solid;
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_facebook.png') 6px 6px no-repeat;
}
.loginBtn--facebook:hover,
.loginBtn--facebook:focus {
  background-color: #5B7BD5;
  background-image: linear-gradient(#5B7BD5, #4864B1);
}


/* Google */
.loginBtn--google {
  /*font-family: "Roboto", Roboto, arial, sans-serif;*/
  background: #DD4B39;
}
.loginBtn--google:before {
  border-right: #BB3F30 1px solid;
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_google.png') 6px 6px no-repeat;
}
.loginBtn--google:hover,
.loginBtn--google:focus {
  background: #E74B37;
}

使用上面相同的代码我决定添加Twitter按钮。我更改了颜色等,但是当我将背景更改为TWITTER徽标时,我没有在页面上显示,我无法理解为什么。我的twitter按钮代码: HTML

<button class="loginBtn loginBtn--twitter"><%= link_to "Sign in with Twitter", sign_in_with_twitter_path, class: 'text-light' %></button>

CSS:

    /* Twitter */
.loginBtn--twitter {
  background-color: #53ADE9;
  background-image: linear-gradient(#53ADE9, #53ADE9);
  text-shadow: 0 -1px 0 #53ADE9;
}
.loginBtn--twitter:before {
  border-right: #3a90c9 1px solid;
  background: url('http://p10cdn4static.sharpschool.com/UserFiles/Servers/Server_208743/Image/twitter2.png') 6px 6px no-repeat;
}
.loginBtn--twitter:hover,
.loginBtn--twitter:focus {
  background-color: #70bcef;
  background-image: linear-gradient(#70bcef, #70bcef);
}

为什么带有我的网址的背景资源不适用?

1 个答案:

答案 0 :(得分:0)

你的推特图片很大。真的很大

在此处查看我的示例 - https://jsfiddle.net/ta0emnmh/

你的推特风格应该是这样的:

.loginBtn--twitter:before {
    border-right: #3a90c9 1px solid;
    background: url(http://p10cdn4static.sharpschool.com/UserFiles/Servers/Server_208743/Image/twitter2.png) 1px 4px no-repeat;
    background-size: contain;
}