Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
Can't figure out how to center this button & header on desktop or this image on mobile

I have this code for a custom block on my website but I'm stuck trying to figure out how to vertically center my button and header in the block.

I also have a centering problem with the image on the tablet and mobile versions.

Anytime I have tried to adjust the desktop and get it vertically centered the mobile version messes up.

Here is the code I have set up:

.custom-html-block {
  padding: 20px;
  border: 5px solid #388697;
  border-radius: 0px;
  margin: 30px 0 40px;
  overflow: hidden;
}

.btn-buy-links {
  float: right;
  width: 55%;
  overflow: hidden;
}

a.box-title {
  display: block;
  font-size: 22px;
  text-decoration: none;
  font-weight: bold;
  text-align: center;
  margin-bottom: 20px;
}

a.btn-amazon,
a.btn-chewy {
  display: block;
  padding: 20px;
  background: #5080C9;
  text-align: center;
  margin: 5px 5px 0;
  color: #fff;
  text-transform: uppercase;
  text-decoration: none;
  font-weight: bold;
  border-radius: 40px;
}

@media only screen and (max-width: 800px) {
  .btn-buy-links {
    float: none;
    width: 100%;
  }
  .custom-html-block img {
    text-align: center;
  }
}

Desktop View - Tablet/Mobile View

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use flexbox and center. You can use grid too but flexbox is easier.

over 4 years ago · Santiago Trujillo Report

0

How can I vertically center a div element for all browsers using CSS? does this help? I had this same issue yesterday and this helped me, if not search up vertically centre HTML, CSS.

over 4 years ago · Santiago Trujillo Report

0

I would suggest using Flexbox since it will make everything easier for you. With Flexbox you can center elements both vertically and horizontally.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!