I'm trying to put a button in the lower left of a containing div regardless of how the text above it changes, but everything I've tried either doesn't work or puts the button relative to the SCREEN, not to the DIV.
#becomememberform {
position: relative;
bottom: 0;
left: 0;
}
#pagelanding_calltoaction {
width: calc(100% - 500px);
height: 100%;
padding: 20px;
float: left;
position: relative;
}
<div id="pagelanding_calltoaction">
<h1>Title</h1>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum massa id nisi consequat vulputate sit amet et dui.
</p>
<form method="get" action="/kontakt" id="becomememberform">
<button id="becomemember" type="submit" style="width:80%; padding:20px;"><h2>Bliv medlem</h2></button>
</form>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
How do I get the button to permanently sit in the lower left corner of #pagelanding_calltoaction, instead of the screen? Apologies if this has been asked before, every other answer I've found tries to put it relative to the screen, not the containing div.
CodePudding user response:
Here is the code to set position of button at bottom left corner of the div. You need to set the form wrapper relative and the form to be absolute position.
#becomememberform {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: auto;
}
#pagelanding_calltoaction {
width:calc(100% - 500px);
height:100%;
padding:20px 20px 200px;
float:left;
position:relative;
}
here is the codepen link to check: https://codepen.io/atitmistry89/pen/MWEKved
CodePudding user response:
Is this what you are looking for?
#becomememberform {
position: fixed;
bottom: 0;
left: 0;
}
#pagelanding_calltoaction {
width: calc(100% - 500px);
height: 100%;
padding: 20px;
float: left;
position: relative;
}
<div id="pagelanding_calltoaction">
<h1>Title</h1>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum massa id nisi consequat vulputate sit amet et dui.
</p>
<form method="get" action="/kontakt" id="becomememberform">
<button id="becomemember" type="submit" style="width:80%; padding:20px;"><h2>Bliv medlem</h2></button>
</form>
</div>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
#pagelanding_calltoaction {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
}
Try adding this style instead of yours, the only edit is changed position from relative to absolute and add a width 100%.