相关疑难解决方法(0)

如何在css中的图像上定位文本

如何将文本居中在css中的图像上?

<div class="image">
    <img src="sample.png"/>
    <div class="text">
       <h2>Some text</h2>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我想做类似下面的事情,但我遇到了困难,这是我现在的css

<style>
.image {
   position: relative;
}

h2 {
   position: absolute;
   top: 200px;
   left: 0;
   width: 100%;
   margin: 0 auto;
   width: 300px;
   height: 50px;
}
</style>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

当我使用background-image时,我没有得到html2pdf的任何输出:

<style>
#image_container{
    width: 1000px;
    height: 700px;
    background-image:url('switch.png');
}
</style>
<a href="prints.php">Print</a>
<?php ob_start(); ?>
<div id="image_container"></div>
<?php 
$_SESSION['sess'] = ob_get_contents(); 
ob_flush();
?>
Run Code Online (Sandbox Code Playgroud)

这是prints.php:

<?php require_once('html2pdf/html2pdf.class.php'); ?>
<?php
$html2pdf = new HTML2PDF('L', 'A4', 'en');
$html2pdf->writeHTML($_SESSION['sess']);
$html2pdf->Output('random.pdf');
?>
Run Code Online (Sandbox Code Playgroud)

html css

122
推荐指数
4
解决办法
55万
查看次数

Bootstrap 3:图像上的文本覆盖

我使用bootstrap 3缩略图如下:

<div class="thumbnail">
    <img src="/img/robot.jpg" alt="..." />
    <div class="caption post-content">
        <h3>Robots!</h3>
        <p>Lorem ipsum dolor sit amet</p> 
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我希望caption覆盖图像,但在Mashable.com上的方式

我试过以下但没有运气:((

.post-content {
    background: none repeat scroll 0 0 #FFFFFF;
    opacity: 0.5;
    margin: -54px 20px 12px; 
    position: relative;
}
Run Code Online (Sandbox Code Playgroud)

如何caption在图像顶部覆盖div,但就像(Mashable.com)一样?

这有效,但我希望它像Mashable一样居中.并以每个图像为中心.对于某些图像,它不是居中的.

html css css3 twitter-bootstrap-3

30
推荐指数
2
解决办法
12万
查看次数

标签 统计

css ×2

html ×2

css3 ×1

twitter-bootstrap-3 ×1