简体   繁体   English

背景图片无法正确显示

[英]background image not displaying correctly

i was working on this site itsquad.us .I need to add my toll free number under the banner with a background image .the code is 我在此站点itsquad.us上工作。我需要在带有背景图片的横幅下添加免费电话号码。代码是

 <div class="call"><p>1-855-566-6006</p></div></div>

css CSS

.call
{
color: #FD7800;
font-weight: bold;
font-size: 23px;
background:url('http://itsquad.us/wp-content/uploads/2014/06/tollfree1.png') no-repeat;
}

But the image is displaying at the left of the div .I have no idea what is happening. 但是图像显示在div的左侧。我不知道发生了什么。 I have tried giving margin,postion,padding etc in css which didn't help .I want it in the center just over the homepage banner.please help me.thanks!! 我试图在css中给margin,postion,padding等没有帮助。我希望它在主页横幅上方的中间。请帮助我。谢谢!!

Try this: 尝试这个:

CSS CSS

.call { 
     background: url("http://itsquad.us/wp-content/uploads/2014/06/tollfree1.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0); 
     color: #FD7800; 
     font-size: 23px; 
     font-weight: bold; 
     height: 90px; 
     padding-left: 70px; 
     width: 150px; 
}

.call p { 
     margin: 0; 
     position: relative; 
     top: 22px; 
}

HTML HTML

<div class="call"><p>1-855-566-6006</p></div>

I hope my example will help Codepen demo 希望我的示例对Codepen演示有所帮助

HTML HTML

<div class="call"><p>1-855-566-6006</p></div>

CSS CSS

body {
  background: #ececec;
}
.call
{
color: #FD7800;
font-weight: bold;
font-size: 23px;
background:url('http://itsquad.us/wp-content/uploads/2014/06/tollfree1.png') no-repeat;
background-size:contain;
width: 500px;
height: 160px;
display:block;
}
.call p {
  padding-top:50px;
  text-align:center;
}

In the background URL, try to upload image in an uploading website (and paste the URL). 在后台网址中,尝试在上传网站中上传图片(并粘贴网址)。 Don't forget to make the height and width. 不要忘记设定高度和宽度。

.yourCLASS{ 
 width: ?;
 height: ?;   
background: url(....);}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM