CSS 底部和中心垂直对齐

标签 css vertical-alignment text-alignment

我找到了很多解决方案,但没有一个对我有用。 在以下标记中,文本“lorem ipsum example”应在底部对齐并居中。我似乎无法弄清楚!

#box {
		background:#6CCB61	
	}
	.wrapper div {
		height: 240px;
        width:100%;
		margin: 10px 0 20px 0;
		box-sizing:border-box;
		padding: 10px;
		color:white;
		text-align:center;
	}
	#boxGreen span {
		vertical-align: bottom;
	}

	.wrapper {
		width:auto;		
		margin: 0 10px;
	}
	#boxGreen {
		width:100%;	
	}
}
<div class="wrapper">        
        <div id="box">
        	<span>Lorem Ipsum Example</span>
        </div>
</div>

最佳答案

试试这个:

#box {
    background:#6CCB61;
    position: relative;
}

#box span {
    position: absolute;
    width: 100%;
    left: 0;
    bottom: 0;
}

https://jsfiddle.net/veefmgna/

关于CSS 底部和中心垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39634186/

相关文章:

Python 正则表达式全局用空格替换尾随零

javascript - 如何使用 javascript/jQuery 激活菜单链接?

css - 以未知宽度居中元素

css - 基于其底部边缘的中间放置文本 block

html - 不同浏览器的行高和字体大小?

html - 垂直对齐流体 DIV 中的内容

css - 在 CSS Sprite 下对齐文本

ios - 在 UILabel 中将文本垂直对齐到顶部

css - 如何使 WP 侧边栏具有响应性并在小屏幕上显示在页面底部?

css - 变换旋转和平移圆形图像到另一个图像内