Jump to content

Centering a coded button within Code block

Go to solution Solved by Spark-Plugin,

Recommended Posts

Posted

Site URL: https://www.shearwatercove.com/

I am using code to embed a button into a code block. I am copying and pasting the HTML code from the third party service into the code block. How do I center the button itself within the code block? Disclaimer - I am not familiar with coding at all. Can someone tell me what and exactly where to insert into my HTML below the necessary css to center the button? Thank you!

<button class='flybook-book-now-button fb-widget-type-frontend fb-default-category-id-0 fb-account-id-1477 fb-entity-config-id- fb-domain-go.theflybook.com fb-protocol-https' style='background-color: #36b5aa;'>BOOK NOW!</button><link rel='stylesheet' href='https://go.theflybook.com/content/bootstrapper/flybookbootstrap.css' /><script src='https://go.theflybook.com/custom/bootstrapper/flybookbootstrap.js'></script>

  • Replies 2
  • Views 126
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

  • Solution
Posted (edited)

Hello, @JasonWilson You can definitely center the button within the code block! Just replace your current code with this updated one below. See attached screeshot for reference:

<div class="button-container">
  <button class="flybook-book-now-button fb-widget-type-frontend fb-default-category-id-0 fb-account-id-1477 fb-entity-config-id- fb-domain-go.theflybook.com fb-protocol-https" style="background-color: #36b5aa;">BOOK NOW!</button>
</div>

<link rel="stylesheet" href="https://go.theflybook.com/content/bootstrapper/flybookbootstrap.css" />
<script src="https://go.theflybook.com/custom/bootstrapper/flybookbootstrap.js"></script>

<style>
  /* Center the button horizontally */
  .button-container {
    display: flex !important; /* Enables flexbox layout for alignment */
    justify-content: center !important; /* Horizontally centers child elements */
    align-items: center !important; /* Vertically centers child elements */
    width: 100% !important; /* Ensures the container spans the full width of its parent */
  }

  /* Style the button to maintain consistent appearance */
  .flybook-book-now-button {
    padding: 10px 20px !important; /* Adds padding for better button aesthetics */
    font-size: 1rem !important; /* Sets a readable font size */
    border: none !important; /* Removes any default borders */
    cursor: pointer !important; /* Changes cursor to a pointer on hover */
    text-align: center !important; /* Ensures text is centered inside the button */
  }

  /* Optional: Adjust button size for smaller screens */
  @media (max-width: 768px) {
    .flybook-book-now-button {
      font-size: 0.9rem !important; /* Slightly smaller font for mobile */
      padding: 8px 16px !important; /* Adjust padding for smaller screens */
    }
  }
</style>

 

547_2x_shots_so.thumb.jpeg.bde180afac0a83376320af131812fa14.jpeg

Edited by Spark-Plugin

- Answered by Iuno from sparkplugin.com

forumsignature-recommendedcopy2.png.0579645eb1430dc7c1059541dc6456c6.png

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.