我有一个包装器,里面包含一些信息div.一切都很好,但我不能让它垂直对齐.
如何证明垂直对齐和位于中间的.title和.text类?
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#wrapper {
position: absolute;
width:96.4%;
height:80%;
border:1px solid #1f1e1e;
padding:10px;
}
.info{
position: relative;
width:100%;
height:32%;
background-color:#1b1f1e;
border-radius:6px;
color:#fff;
font-size:18px;
margin-bottom:6px;
}
.title{
background-color:#dc6210;
text-align:center;
height:50%;
line-height:50%;
border-top-left-radius:6px;
border-top-right-radius:6px;
}
.text{
text-align:center;
height:50%;
line-height: 50%;
}Run Code Online (Sandbox Code Playgroud)
<div id="wrapper">
<div class="info">
<div class="title">Title</div>
<div class="text"> "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." </div>
</div>
<div class="info">
<div class="title">Title</div>
<div class="text"> "Neque …Run Code Online (Sandbox Code Playgroud)我创建了一个获得2个参数的命名函数.第一个参数是没有表达式的图像文件名(str).第二个参数是像素的图像高度(num).我想在html文档中显示给定高度的图像.
例如:
<div><script>showImage('test', 100);</script></div>
Run Code Online (Sandbox Code Playgroud)
我相信函数不是正确的方式.如何正确调用函数来显示任何div内的图像.
function showImage (imgfilename, imgheight) {
var img = '';
imgheight = typeof(imgheight) !== "undefined" ? imgheight : "64";
imgheight = 64 + (imgheight - 64);
img += '<img src="https://i.imgsafe.org/'+imgfilename+'.png" width="64px" height="'+imgheight+'px">';
//console.log (img);
return img;
} Run Code Online (Sandbox Code Playgroud)
body {background-color: #ccc;}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="img1"><script>showImage('7a622f4233', 68);</script></div>
<div id="img2"><script>showImage('7a622f4233', 80);</script></div>
<div id="img3"><script>showImage('7a5fa34d31', 60);</script></div>Run Code Online (Sandbox Code Playgroud)