How to align buttons in a row of columns
I have a row of columns that consist of an image some text and a button. How can I have the button on the bottom of each of the columns look aligned.
I tried various flex box methods for example flex-end, however that messes with the rest of the content alignment. I have also used position relative for the parent and position absolute bottom 0 for the button. The the problem with that is it collides with the sibling paragraph tag that might contain a different length of text.
Example Image
!(https://www.dropbox.com/s/9e27ehcnqdsyx89/Screen%20Shot%202019-01-19%20at%2012.26.03%20PM.png?dl=0)
<div class="content" for number of content>
<img
/>
<div class="title">
<h4>Title</h4>
</div>
<div class="body">
<p>Paragraphs of various length</p>
</div>
<a>
<button class="btn btn-default">
CTA
</button>
</a>
</div>
html css flexbox
add a comment |
I have a row of columns that consist of an image some text and a button. How can I have the button on the bottom of each of the columns look aligned.
I tried various flex box methods for example flex-end, however that messes with the rest of the content alignment. I have also used position relative for the parent and position absolute bottom 0 for the button. The the problem with that is it collides with the sibling paragraph tag that might contain a different length of text.
Example Image
!(https://www.dropbox.com/s/9e27ehcnqdsyx89/Screen%20Shot%202019-01-19%20at%2012.26.03%20PM.png?dl=0)
<div class="content" for number of content>
<img
/>
<div class="title">
<h4>Title</h4>
</div>
<div class="body">
<p>Paragraphs of various length</p>
</div>
<a>
<button class="btn btn-default">
CTA
</button>
</a>
</div>
html css flexbox
can you put correct html structure?
– Vedant
Jan 19 at 20:43
add a comment |
I have a row of columns that consist of an image some text and a button. How can I have the button on the bottom of each of the columns look aligned.
I tried various flex box methods for example flex-end, however that messes with the rest of the content alignment. I have also used position relative for the parent and position absolute bottom 0 for the button. The the problem with that is it collides with the sibling paragraph tag that might contain a different length of text.
Example Image
!(https://www.dropbox.com/s/9e27ehcnqdsyx89/Screen%20Shot%202019-01-19%20at%2012.26.03%20PM.png?dl=0)
<div class="content" for number of content>
<img
/>
<div class="title">
<h4>Title</h4>
</div>
<div class="body">
<p>Paragraphs of various length</p>
</div>
<a>
<button class="btn btn-default">
CTA
</button>
</a>
</div>
html css flexbox
I have a row of columns that consist of an image some text and a button. How can I have the button on the bottom of each of the columns look aligned.
I tried various flex box methods for example flex-end, however that messes with the rest of the content alignment. I have also used position relative for the parent and position absolute bottom 0 for the button. The the problem with that is it collides with the sibling paragraph tag that might contain a different length of text.
Example Image
!(https://www.dropbox.com/s/9e27ehcnqdsyx89/Screen%20Shot%202019-01-19%20at%2012.26.03%20PM.png?dl=0)
<div class="content" for number of content>
<img
/>
<div class="title">
<h4>Title</h4>
</div>
<div class="body">
<p>Paragraphs of various length</p>
</div>
<a>
<button class="btn btn-default">
CTA
</button>
</a>
</div>
html css flexbox
html css flexbox
edited Jan 22 at 7:28
Asiya Fatima
564111
564111
asked Jan 19 at 20:40
user7659932user7659932
425
425
can you put correct html structure?
– Vedant
Jan 19 at 20:43
add a comment |
can you put correct html structure?
– Vedant
Jan 19 at 20:43
can you put correct html structure?
– Vedant
Jan 19 at 20:43
can you put correct html structure?
– Vedant
Jan 19 at 20:43
add a comment |
1 Answer
1
active
oldest
votes
Try this:
HTML
<div class="container">
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
</div>
CSS
.container {
display: flex;
}
.item {
display: flex;
flex-flow: column;
}
.item:not(last-child) {
margin-right: 10px;
}
.item__image {
}
.item__content {
flex: 2 ;
}
.item__options {
text-align: center;
height: 100px;
}
view the output here: https://jsfiddle.net/2467mgn5/2/
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54271202%2fhow-to-align-buttons-in-a-row-of-columns%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this:
HTML
<div class="container">
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
</div>
CSS
.container {
display: flex;
}
.item {
display: flex;
flex-flow: column;
}
.item:not(last-child) {
margin-right: 10px;
}
.item__image {
}
.item__content {
flex: 2 ;
}
.item__options {
text-align: center;
height: 100px;
}
view the output here: https://jsfiddle.net/2467mgn5/2/
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
add a comment |
Try this:
HTML
<div class="container">
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
</div>
CSS
.container {
display: flex;
}
.item {
display: flex;
flex-flow: column;
}
.item:not(last-child) {
margin-right: 10px;
}
.item__image {
}
.item__content {
flex: 2 ;
}
.item__options {
text-align: center;
height: 100px;
}
view the output here: https://jsfiddle.net/2467mgn5/2/
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
add a comment |
Try this:
HTML
<div class="container">
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
</div>
CSS
.container {
display: flex;
}
.item {
display: flex;
flex-flow: column;
}
.item:not(last-child) {
margin-right: 10px;
}
.item__image {
}
.item__content {
flex: 2 ;
}
.item__options {
text-align: center;
height: 100px;
}
view the output here: https://jsfiddle.net/2467mgn5/2/
Try this:
HTML
<div class="container">
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
<div class="item">
<div class="item__image"><img src="https://dummyimage.com/300x300/000/fff" /></div>
<div class="item__content">
<div class="item__title"><h4>Title</h4></div>
<div class="item__body"><p>Paragraphs of various lenthParagraphs of various lengthParagraphs of various length</p></div>
</div>
<div class="item__options">
<button class="btn btn-default">CTA</button>
</div>
</div>
</div>
CSS
.container {
display: flex;
}
.item {
display: flex;
flex-flow: column;
}
.item:not(last-child) {
margin-right: 10px;
}
.item__image {
}
.item__content {
flex: 2 ;
}
.item__options {
text-align: center;
height: 100px;
}
view the output here: https://jsfiddle.net/2467mgn5/2/
edited Jan 19 at 21:27
answered Jan 19 at 21:01
Jesse James BurtonJesse James Burton
20119
20119
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
add a comment |
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
That works until you encounter a p tag that contains more or less text than the other item__bodys
– user7659932
Jan 19 at 21:08
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
Ahh yeah, I see what you mean. Hmm I am playing around with using flex within the item with flex-direction: column but that seems to have the same problem.
– Jesse James Burton
Jan 19 at 21:14
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
I think I got it, try the fiddle again. jsfiddle.net/2467mgn5/2
– Jesse James Burton
Jan 19 at 21:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54271202%2fhow-to-align-buttons-in-a-row-of-columns%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can you put correct html structure?
– Vedant
Jan 19 at 20:43