Adjust the text to fit neatly within a circular-shaped column container

I am currently working with Bootstrap 5 and I have a row with two columns positioned next to each other. My goal is to apply rounded borders to the left column while ensuring that the content remains within the div.

Below is the code snippet:

<div class="row">
    <div class="col-6 rounded-pill border clinic-header">
        <div class="col-md-12 p-2">
            <h2>{{clinic.name}}</h2>
            <h5><img src="{% static 'img/icons/hospital.svg' %}">{{clinic.get_speciality_display}}</h5>
            <h5><img src="{% static 'img/icons/geo-alt.svg' %}">{{clinic.full_address}}</h5>
            <h5><img src="{% static 'img/icons/train-front.svg' %}">{{clinic.train_access}}</h5>
            <h5><img src="{% static 'img/icons/bus-front.svg' %}">{{clinic.bus_access}}</h5>
            <h5><img src="{% static 'img/icons/p-square.svg' %}">{{clinic.parking}}</h5>
            <h5><img src="{% static 'img/icons/telephone.svg' %}">{{clinic.phone_number}}</h5>
        </div>
    </div>

Here is the custom CSS class being used:

.clinic-header {
    shape-outside: margin-box;
}

You can view the current result here.

I have experimented with adjusting the overflow and shape-outside properties in the CSS, but have not been successful in keeping the text inside the div and adjusting padding accordingly. Any suggestions on how this can be achieved?

Answer №1

Here is your modified HTML code:

<div class="row mx-0">
      <div class="col-6 clinic-header">
        <div class="py-5">
          <h2>{{clinic.name}}</h2>
          <h5>
            <img
              src="{% static 'img/icons/hospital.svg' %}"
            />{{clinic.get_speciality_display}}
          </h5>
          <h5>
            <img
              src="{% static 'img/icons/geo-alt.svg' %}"
            />{{clinic.full_address}}
          </h5>
          <h5>
            <img
              src="{% static 'img/icons/train-front.svg' %}"
            />{{clinic.train_access}}
          </h5>
          <h5>
            <img
              src="{% static 'img/icons/bus-front.svg' %}"
            />{{clinic.bus_access}}
          </h5>
          <h5>
            <img
              src="{% static 'img/icons/p-square.svg' %}"
            />{{clinic.parking}}
          </h5>
          <h5>
            <img
              src="{% static 'img/icons/telephone.svg' %}"
            />{{clinic.phone_number}}
          </h5>
        </div>
      </div>
 </div>

Remember to style your CSS accordingly:

.clinic-header {
        border: 1px solid gray;
        border-radius: 50%;
        display: flex;
        justify-content: center;
 }

Answer №2

To enhance the radius container, make sure to include:

text-align: center; min-width: max-content; padding: 20px 0;
.

Give it a try:

.heading-clinic {
  shape-outside: margin-box;
}
.rounded-pill{
  border-radius: 200px;
  text-align: center;
  min-width: max-content;
  padding: 20px 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afcdc0c0dbdcdbddcedfef9b819f819f">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="row">
  <div class="col-6 rounded-pill border heading-clinic">
    <div class="col-md-12 p-2">
      <h2>{{clinic.name}}</h2>
      <h5><img src="{% static 'img/icons/hospital.svg' %}">{{clinic.get_speciality_display}}</h5>
      <h5><img src="{% static 'img/icons/geo-alt.svg' %}">{{clinic.full_address}}</h5>
      <h5><img src="{% static 'img/icons/train-front.svg' %}">{{clinic.train_access}}</h5>
      <h5><img src="{% static 'img/icons/bus-front.svg' %}">{{clinic.bus_access}}</h5>
      <h5><img src="{% static 'img/icons/p-square.svg' %}">{{clinic.parking}}</h5>
      <h5><img src="{% static 'img/icons/telephone.svg' %}">{{clinic.phone_number}}</h5>
    </div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Grid of domes, fluid contained within fixed structures and beyond

I've been grappling with this issue for a while now, and have had to rely on jQuery workarounds. I'm curious if there is a way to achieve this using CSS or LESS (possibly with javascript mixins). The page in question consists of both fixed and f ...

javascript The unchecking of a checkbox is not functioning

I am facing an issue with this JavaScript code. The problem is that when I uncheck a value, it removes all the values from the result instead of removing just the specific unchecked value. Can someone please help me with this? <script> window.addE ...

What is the best method for eliminating HTML line breaks <br />?

I have gathered a collection of reviews from web scraping, but unfortunately they are filled with unwanted <br \> tags. Even after cleaning the data by removing stopwords, I still find several lingering instances of the "br" tag in the dataset. ...

Is it acceptable to debut a full-screen iframe widget compared to an embedded one?

My current project involves integrating a custom widget into users' websites for my application. I am considering using an iframe as it seems to be the most efficient option for several reasons: Utilizing the custom framework of the application will ...

The dropdown menus in Bootstrap are expanding outside the screen when opened

When I click on the dropdown in the Navbar on the right side, the menus open up far to the right and are not visible until I scroll horizontally. Here is the code snippet: <nav class="navbar navbar-expand-lg navbar-light bg-light"> < ...

Jekyll adjusting the starting line of code snippet formatting

Currently, I'm in the process of setting up code highlighting for my blog using Jekyll and Pygments. However, I'm facing an issue where the first line of every code snippet seems to be slightly offset. To create a gutter effect, I'm utilizin ...

Changing the color of text in an HTML input field using CSS and JavaScript depending on the input value

Looking for a solution! // Getting user input values var input1 = parseInt(document.getElementById("input1").value); var input2 = parseInt(document.getElementById("input2").value); var input3 = parseFloat(document.getElementById(" ...

What is the best way to apply a 2px padding to text-decoration: underline?

As a dedicated frontend developer, I believe in creating underlines with a 2px padding instead of the default 1px. Is there an easy solution for achieving this? PS: Yes, I am aware of using a div with a black background color and 1px * Npx with position: ...

Having trouble displaying a local image in CSS using EJS

Hey there, I'm currently working with EJS. In my CSS file, I've added a background image but it's not showing up when the page loads. Strangely, if I use a hosted image, it works perfectly. Here is my directory structure: https://i.sstatic ...

Manipulate a table using Jquery's find() method to insert a cell populated with information from an array using before()

My current challenge involves inserting a column of cells with data from an array. Despite attempting to use a for loop, all the cells end up displaying the same data from the array. What I really want is for each new cell to show 'row_header1', ...

Compiling 'react-scripts' to include a few images as data URIs within the CSS file

I have recently inherited a sizable React project, even though my experience with React is limited. Nonetheless, I am attempting to make improvements in areas where I feel confident. An ongoing issue we are facing is the excessive size of our main CSS fil ...

Having issues with Div CSS functionality not properly functioning

My background CSS is working fine, but the styling for the .about div is not applying. Here is my HTML code: <DOCTYPE! HTML> <head> <link rel="stylesheet" type="text/css" href="CSS.css"> </head> <body> ...

Ways to centrally position elements in a Bootstrap table

I came across this query and tried implementing the style mentioned, but unfortunately, my table items are not aligned vertically: https://i.sstatic.net/rMqSR.png This is how the HTML appears: .table > tbody > tr > td { vertical-align ...

jQuery Mobile panel buttons are functioning properly within a maximum width of 300 pixels

I have constructed a panel that adjusts its size based on the device's screen using responsive design techniques. The code for this panel is as follows: <div data-role="panel" data-position="right" data-display="overlay" data-theme="a" id="add-for ...

What is the trick to showing text underneath a font awesome icon?

My HTML code contains font awesome icons, and I'm looking to have text appear below each icon instead of next to it. Currently, the text is displayed midway to the right of each icon. <div class="icons"> <span class="fa-stack f ...

What is the best way to determine the accurate size of a div's content?

There are 2 blocks, and the first one has a click handler that assigns the block's scrollWidth to its width property. There is no padding or borders, but when the property is assigned, one word wraps to the next line. The issue seems to be that scrol ...

Adjusting the characteristics of a class when hovering

Is it possible to change the CSS property of a class when hovering over another class in CSS? #_nav li { display:inline; text-decoration:none; padding-top:5vh; line-height:8vh; margin-right:5vh; cursor:pointer; } #_nav li:hover + ...

Building a Compact Dropdown Menu in Bootstrap

I am looking to implement a compact Bootstrap dropdown feature, but I am unsure of how to do it. Take a look at this image for reference. base.html: <a class="text-light" data-bs-toggle="dropdown" aria-expanded="false&qu ...

What is the best way to ensure that a specified number of list items (li) will align properly within the width of an unordered list (ul

I'm attempting to make all the li elements' width match that of my ul element. Here is the code I am using: http://jsfiddle.net/4XR5V/2/ I have looked at some similar questions on the website and tried adding: ul { width: 100%; display: tab ...

What is the best way to center my items vertically in a material-UI Grid row?

Struggling to vertically align three items in a row using Material UI's Grid component. Despite setting "justifyContent: 'center'," it only horizontally centers the items. Here are my styles: const styles = (theme) => ({ root: { te ...