html - 如何在 Canvas 元素旁边的中间对齐文本

标签 html css

我需要我的文本元素位于 div 的中间和我的 Canvas 元素旁边。目前,文本在旁边但不在中间。我怎样才能达到这种效果?

顺便说一句, Canvas 包含一个图表插件,我没有包含在下面的代码片段中。

#user-count {
  height: 100px;
  width: 100px;
}

.card {
  background-color: #f4f4f4;
  border: none;
  padding:10px;
  display: inline-block;
}

.card-body {
  font-weight: 600;
  text-transform: uppercase;
  display: inline-block;
}
<div class="row">
	<div class="col-md-6">
		<div class="card">
		  <canvas id="user-count"></canvas>
		 		<div class="card-body">
		 			<span>current blood donors</span>
		 			<span>as of 2017</span>
		 		</div>
		</div>
</div>

最佳答案

类似于 Flex :)

#user-count {
  height: 100px;
  width: 100px;
  background-color: red;
}

.card {
  background-color: #f4f4f4;
  border: none;
  padding: 10px;
  display: inline-block;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-body {
  font-weight: 600;
  text-transform: uppercase;
  display: inline-block;
}
<div class="row">
  <div class="col-md-6">
    <div class="card">
      <canvas id="user-count">
		 						 </canvas>
      <div class="card-body">
        <span>current blood donors</span>
        <span>as of 2017</span>
      </div>
    </div>
  </div>

关于html - 如何在 Canvas 元素旁边的中间对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50175302/

相关文章:

jquery - 如何设置视频 iFrame 的样式?

css - 不同页面上的相同页脚 div 看起来不同

javascript - 在 Javascript 中以编程方式复制和选择跨度(使用 clipboard.js)

javascript - 为什么 <th> 或 <td> 边框在 mozilla 和 IE 中没有显示(我在这些 <th> 或 <td> 上使用了 Jquery UI resizable() 函数),但在 chrome 中却工作正常?

javascript - Bing map 在 Chrome 上显示,但在 IE 上不显示

html - struts2 元素的布局页面出现不需要的边框

html - 圆圈css3问题中的中心文本

关于翻转 Angular 和受影响级别的CSS

html - 网络安全字体是否需要购买许可证才能在商业网站上使用?

php - 在 Wordpress 中,如何根据用户所在的页面更改链接的目标?