php - 以小背景显示文本

标签 php css

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 8 年前

我在显示某些文本的背景时遇到了一些问题。 背景应该与一些(真实的)文本一起显示(在中心),就像一个按钮但不可点击。 我有一张 150x24 像素的背景图片。 然而,一旦使用我的 css 显示,按钮的大小可达 940x150。

因为我是 CSS 的初学者,我想我在这里遗漏了一些东西......

我的代码看起来像

<div class="wrap"> <img src=sites/all/themes/at_subtheme/css/img/header.jpg>

    <div class="caption">

       <div class="caption-inner">
           <div class="caption-content">
              <?php if  ((( user_is_anonymous())) or (in_array('administrator', array_values($user->roles))) ) :?>
              <h2 class="loginlink"> <a href="http://www.example.com">Login</h2></a><?php endif; ?>  
              <h2 class="mybackgroundtext">Mybackgroundtext</h2>
              <img class="button"> <img src=sites/all/themes/at_subtheme/css/img/button.jpg>
              <h2 class="headerposition">My headertext</h2>
              <h6 class="subheaderposition">mysubheadertext</h6>
              <h6 class="subsubheaderposition">Mysubsubheadertext</h6>
           </div>
       </div>
    </div>
</div>

最佳答案

我不确定你到底想做什么。我只拿了你的按钮代码并制作了一个带有几个选项的 JSFIDDLE。谢谢,

button fiddle

<div class="caption"> 
    <a target="_blank" title="Microsoft" class="btn btnImgContainer" href="http://www.microsoft.com/en- us/default.aspx"> 
        <img class="myImage" src="http://c.s-microsoft.com/en-us/CMSImages/mslogo.png?version=856673f8-e6be-0476-6669-d5bf2300391d" />
    </a>  
    <a target="_blank" class="btn btnContainer" href="#">Mybackgroundtext</a>  
    <a target="_blank" class="btn btnImgBackground" href="#">My Different Button</a>

</div>

.btn {
    margin: 10px;
    width: 200px;
    height: 100%;
    padding: 10px;
    float: left;
    text-align: center;
    text-decoration: none;
}
.btn:hover {
    padding-top: 15px;
    text-decoration: underline;
}
.myImage {
    width: 100%;
    /*The height 100% distorts image*/
    height: 100%;
}
.btnImgContainer {
    width: 150px;
}
.btnContainer {
    background: blue;
    color: white;
}
.btnImgBackground {
    background: url("http://www.psdgraphics.com/file/abstract-background.jpg");
    background-size: 100%;
    background-repeat: no-repeat;
    color: white;
}

关于php - 以小背景显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25726839/

上一篇:html - 3D 转换卡翻转动画不适用于 chrome

下一篇:javascript - 测试对齐 'Center' 到 highchart 图例内容

相关文章:

php - InvalidArgumentException : The current node list is empty. PHP-Spider (DOMCrawler Symfony)

php - 谷歌语音 API "Sample rate in request does not match FLAC header"

javascript - 如何通过ajax函数发送数据到php文件?

html - 并排放置两列

CSS :not pseudo class is not taking effect

php - 不要重复字符串多次

php - 导出为 csv 时,货币英镑显示为 £

css - 带有 TinyMce 编辑器的 CakePHP : Numbered and bulleted lists not appearing in view. ctp

css - react, css) 用于淡入和淡出的过渡 css,当使用 className 更改背景图像时

javascript - addEventListener 仅触发第一个事件