I have the following markup:
<div class="ml-auto text-right">
<button class="btn btn-next mobile" />
</div>
And css
:
@media screen and (max-width: 576px) {
.mobile {
width: 100%;
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
display: block;
text-align: center;
}
}
I would like to display the button aligned right on desktop and expand to full width on mobile.
However, the above is not working.
What is the correct way to achieve this?
4
Answers
by using the common mobile-first approach you can simplify things:
here’s the pen
Try this updated CSS, use the parent class to avoid any conflict
The provided code does not affect your requirement. You need to add CSS to the button
div
container.In the HTML add a class for button container
div
.Add the CSS for the container to be right aligned in desktop. Your
mobile
media query handles the mobile screen where it will occupy the full width.I have tried the above code: https://jsfiddle.net/rekhaDarshna/yv4fg9ew/
Let me know if there is anything missing.