Socket
Socket
Sign inDemoInstall

bootstrap-center-div-vertically-and-horizontally

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bootstrap-center-div-vertically-and-horizontally

Responsive Center div vertically and horizontally built with Bootstrap 5. To center div both vertically and horizontally use flexbox utilities. See the example.


Version published
Weekly downloads
12
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

How to center div vertically and horizontally

Add .d-flex to the parent element to create a flexbox container and transform into flex items.

Add .align-items-center to the parent element to center its content vertically.

Add .justify-content-center to the parent element to center its content horizontally.

#1

first template


<div class="d-flex align-items-center justify-content-center" style="height: 250px;">
    <div class="p-2 m-2 bg-info text-white shadow rounded-2">Flex item</div>
    <div class="p-2 m-2 bg-info text-white shadow rounded-2">Flex item</div>
    <div class="p-2 m-2 bg-info text-white shadow rounded-2">Flex item</div>
</div>

Much more examples and a detailed description can be found at 📄 Documentation page

Keywords

FAQs

Last updated on 26 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc