i wanted to move a element up, i tried with margin-top, but it seems it doesnt work.
#nextquestion {
margin-left: 80%;
width: 15%;
background-color: #333333;
height: 40%;
color: white;
font-size: 20px;
border: none;
margin-top: 0.01%;
display: inline-block;
}
#question1 {
color: white;
margin-left: 2.5%;
font-size: 31px;
margin-top: 5%;
}
<div style="background-color: #161624; width: 100%; height: 20%; vertical-align: bottom ; " d>
<a id="question1" style="display: inline-block;">Question 1/X</a>
<button id="nextquestion">Next Question</button>
</div>
I have added display: inline-block, but it didnt change anything.
enter image description here Margin-top: -..., doesnt change a lot
CodePudding user response:
That's not the right way to do it in my opinion. Using negative margins is not a good practice. I would instead use flex to achieve it:
#question-container {
background-color: #161624;
display: flex;
flex-direction: row;
height: 20%;
justify-content: space-between;
padding: 3rem;
}
#nextquestion {
width: 15%;
min-width: 120px;
background-color: #333333;
color: white;
font-size: 20px;
border: none;
}
#question1 {
color: white;
font-size: 31px;
}
<div id="question-container">
<a id="question1" style="display: inline-block;">Question 1/X</a>
<button id="nextquestion">Next Question</button>
</div>
CodePudding user response:
Try to add position & top.
add this in your code:
position: relative;
top: -36px;
CodePudding user response:
You can fix it with this code :
div{
background-color: #161624;
width: 100%;
justify-content: space-between;
display: flex;
}
#question1 {
color: white;
margin: 40px;
font-size: 31px;
}
#nextquestion {
width: 15%;
background-color: #333333;
color: white;
font-size: 20px;
height: 44px;
border: none;
}
<div>
<a id="question1" style="display: inline-block;">Question 1/X</a>
<button id="nextquestion">Next Question</button>
</div>
CodePudding user response:
Use flex and then align-self:
*{
box-sizing: border-box;
}
#container{
background-color: #161624;
display: flex;
justify-content: space-between;
height: 100px;
align-items: center;
padding: 0 20px;
}
#container div:first-child{
width: 40%;
}
#container div:last-child{
width: 35%;
align-self: flex-start; /*here! remove this if you want placed in the center vertically.*/
}
#nextquestion {
background-color: #333333;
color: white;
font-size: 20px;
border: none;
padding: 10px;
}
#question1 {
color: white;
margin-left: 2.5%;
font-size: 31px;
margin-top: 5%;
text-decoration: none;
}
<div id="container">
<div><a href="#" id="question1">Question 1/X</a></div>
<div><button id="nextquestion">Next Question</button></div>
</div>
