css Flexbox对齐按钮

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css Flexbox对齐按钮相关的知识,希望对你有一定的参考价值。


 <div class="row">		
		<div class="primary col">
			<h2>Welcome!</h2>
      
			<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.         Donec odio. </p>
      
			<a class="button" href="#">Learn More</a>
		</div><!--/.primary-->
		
		<div class="secondary col">
			<h2>Flexbox is so cool!</h2>
      
			<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
         Donec odio. </p>
      
			<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
         Donec odio. </p>
      
			<a class="button" href="#">Learn More</a>
		</div><!--/.secondary-->
			
		<div class="tertiary col">
			<h2>Another heading</h2>
			<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
         Donec odio. Lorem ipsum dolor sit amet, consectetuer 
         adipiscing elit. Donec odio. </p>
      
			<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
         Donec odio. Lorem ipsum dolor sit amet, consectetuer 
         adipiscing elit. Donec odio. </p>
      
			<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
         Donec odio. Lorem ipsum dolor sit amet, consectetuer 
         adipiscing elit. Donec odio. </p>
      
			<a class="button" href="#">Learn More</a>
		</div><!--/.tertiary-->	
	</div>
/* ================================= 
  Base Element Styles
==================================== */

* {
	box-sizing: border-box;
}
body {
	font-family: 'Varela Round', sans-serif;
	line-height: 1.6;
	color: #3a3a3a;
	margin: 0;
}

p {
	font-size: .95em;
	margin: 0 0 1em 0;
}

h2,
h3,
a {
	color: #093a58;
}

h2,
h3 {
	margin: 0 0 .8em 0;
}

a {
	text-decoration: none;
}

/* ---- Layout Containers ---- */

.col {
	padding: 1em;
	background: #edf4f7;
	border-radius: .35em;
	margin: 0 .5em .8em;
}

/* ---- Page Elements ---- */

.button {
	color: #fff;
	text-align: center;
	padding: .625em 1.25em;
	background: #3acec2;
	border-radius: .35em;
}

/* ================================= 
  Media Queries
==================================== */

@media (min-width: 769px) {
	.row
  {
		width: 90%;
		margin: 1em auto;
	}
	.row,
  .col {
		display: flex;
	}
  

	.col {
		flex: 1;
    flex-direction: column;
	}
  
  .button {
    margin-top: auto; 
    align-self: flex-start; /* Or flex-end to align right */
   }
  
}
@media (min-width: 1025px) {
	.row {
		width: 80%;
		max-width: 1150px;
	}  
}

以上是关于css Flexbox对齐按钮的主要内容,如果未能解决你的问题,请参考以下文章

css CSS flexbox对齐中心

css Flexbox垂直对齐

css 简单的flexbox后备,只有垂直和水平对齐

CSS Flexbox 居中对齐

CSS Flexbox:对齐项目和对齐内容之间的区别[重复]

CSS Flexbox 右对齐响应式