I need to center two fields ("Call Us" and "Our Email") and make them responsive at the same time. They should stack one on top of the other on a small screen. I have inline CSS to position them correctly on a large screen, as is shown in the image, but they don’t stack on top of each other on a small screen like they should. I used inline CSS because I couldn’t find the CSS file to put the code in. Is it possible to use inline CSS to fix this? If so, this is the inline CSS I have that makes the two fields center properly on a large screen.
<div style="justify-content: center; display:flex; class="row">
<div class="col-xl-4 col-xs-4 col-lg-4 col-md-4 col-sm-4 col-12 footer_contact_info">
Again, this code does not make the two fields responsive, i.e. it doesn’t make them stack on a small screen. Originally there were three fields. The third was "Our Address", but I removed it.
I tried adding inline CSS and was expecting it to be responsive on a small screen but it didn’t work.
2
Answers
It appears that you are using the Bootstrap framework. The class
row
appliesdisplay: flex
, so your inline style is redundant. You should also use thejustify-content-center
class instead of inline styles.You have:
Should be:
It is redundant to specify the same number of columns at every breakpoint. Use the appropriate class for only the breakpoints where you want the changes to occur, as it will apply to all larger breakpoints.
You have:
Should be:
Since you didn’t provide a reproducible example, I am having to guess what your structure is.
add
flex-direction:column
to thestyle
of your firstdiv
and if didn’t work, just removeclass="row"
from the firstdiv
and other classes from seconddiv
e.g:
and by the way, in the column order, the
justify-content
doesn’t have any effect, if you want your items be at the center of your page just replacejustify-content
withalign-items
as I have done above but if you don’t want it to be at the center just ignore and remove that part.