Tips for inserting text inside a circular divider within a rounded rectangle

Here is a div structure:

https://i.sstatic.net/wN1Vm.png

With the following code:

<div class="col-12 p-5 mb-3">
    <div class="mainInfo">
        <div class="circle">
            <img src="larger-logo.jpg"> 
        </div>
    </div>
</div>

I wanted to add text on both sides of the circle shape, so I attempted this:

https://i.sstatic.net/8Sv8B.jpg

Here's my attempt:

<div class="col-12 p-5 mb-3">
    <div class="mainInfo">
        <div class="circle">
            <img src="larger-logo.jpg"> 
        </div>
        <div class="paraDivLeft">
            <h6>Site Name</h6>
            <hr>
            <p>www.sitename.com</p>
            <p><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef86818980af9c869b8a818e828ac18c8082">[email protected]</a></p>
        </div>
        <div class="paraDivRight">
            <p>Address</p>
            <p>Postal Code</p>
            <p><strong>Phone Number</strong></p>
        </div>
    </div>
</div>

However, the result was not what I expected:

https://i.sstatic.net/iKASS.png

How can I properly position the texts on either side of the circle?

Below are the CSS codes used:

.mainInfo{
    background-color: #fff;
    border: .01rem round #e0e1ed;
    border-radius: 20px;
    color: #585CA1;
    width:100%;
    height:5em;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.75);
    margin-top: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle {
    position: relative;
    left:20%;
    width: 9em;
    height: 9em;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.65);
}

.circle img {
    position: absolute;
    max-width: 85%;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

UPDATE:

I included this additional CSS:

.mainInfo{
    background-color: #fff;
    border: .01rem round #e0e1ed;
    border-radius: 20px;
    color: #585CA1;
    width:100%;
    height:5em;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.75);
    margin-top: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle {
    position: relative;
    left:20%;
    width: 9em;
    height: 9em;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.65);
}

.circle img {
    position: absolute;
    max-width: 85%;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}
.paraDivLeft{
  position: absolute;
  left: 16px;
}

.paraDivRight{
  position: absolute;
  right: 16px;
}

Yet, the layout remains unchanged:

https://i.sstatic.net/CXhoM.png

Answer №1

It seems like your current setup is on the right track, but I would suggest adjusting the line height to 1em for better readability.

Here is a modified version with added 'top' and either 'left' or 'right' attributes to ensure proper positioning away from the edges using absolute positioning. Additionally, text-align has been utilized for each paraDiv section:

.mainInfo{
    background-color: #fff;
    border: .01rem round #e0e1ed;
    border-radius: 20px;
    color: #585CA1;
    width:100%;
    height:5em;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.75);
    margin-top: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle {
    position: relative;
    left:20%;
    width: 9em;
    height: 9em;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.65);
}

.circle img {
    position: absolute;
    max-width: 85%;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.paraDivLeft,
.paraDivRight {
    position: absolute;
    display: inline-block;
    padding: 10px;
}

.paraDivLeft {
    left: 20px;
    top: 40px;
    text-align: left;
}

.paraDivRight {
    right: 20px;
    top: 50px;
    text-align: right;
}

.paraDivLeft h6 {
    font-size: 14pt;
    margin: 0;
}

.paraDivLeft p,
.paraDivRight p {
    line-height: 1em;
    font-size: 12pt;
    margin: 0;
}
<div class="col-12 p-5 mb-3">
    <div class="mainInfo">
        <div class="circle">
            <img src="larger-logo.png"> 
        </div>
        <div class="paraDivLeft">
            <h6>Site Name</h6>
            <hr>
            <p>www.sitename.com</p>
            <p><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cca5a2aa...">@[email protected]</a></p>
        </div>
        <div class="paraDivRight">
            <p>Address</p>
            <p>Postal Code</p>
            <p><strong>Phone Number</strong></p>
        </div>
    </div>
</div>

Answer №2

To implement the CSS layout using the position property, you can specify the following position values for the mainInfo, paraDivLeft, and paraDivRight classes in your CSS stylesheet.

.mainInfo{
    position: relative;
    background-color: #fff;
    border: .01rem round #e0e1ed;
    border-radius: 20px;
    color: #585CA1;
    width:100%;
    height:5em;
    box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.75);
    margin-top: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paraDivLeft{
  position: absolute;
  left: 16px;
}

.paraDivRight{
  position: absolute;
  right: 16px;
}

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

The issue arises when trying to apply CSS and minified JavaScript after adding new data in jQuery Mobile

I am having an issue with adding data and displaying it on a list. The problem arises when I add data through AJAX. In the success function, after showing the alert "successfully added", I used location.reload(), which takes me to the homepage (div tag dat ...

What is the method for inserting a newline into a textarea with an HTTPRequest?

Is it possible to print a newline in a textarea using the HTTPRequest property? Here's the code I have: <script> function sendRequest(str) { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } el ...

Adjusting Font Size in Angular Material Design

Recently, I incorporated https://material.angularjs.org/latest/ to optimize the responsive design of my website. One key feature I am focusing on is adjusting the font size based on different screen sizes. For smaller screens, I intend to set the font siz ...

Deactivate a radio button group based on the selection of a previous group

When submitting a pay change request for an employee in the HR Department, there are 2 sets of radio buttons to consider. The 2nd group should only be enabled if "Yes" is selected in the first group. However, if the user switches from "Yes" to something in ...

What is the process for modifying the heading color in Bootstrap's dark mode?

If you want to enable dark mode according to the Bootstrap documentation instructions, follow these steps: <html lang="en" data-bs-theme="dark"> <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel= ...

Submit button not found within the form element

Currently, I am in the process of designing a form layout that does not include a submit button within the <form> tags. Here is an example to clarify: http://codepen.io/timsim/pen/aJjdGa The design concept I am working on requires the input data to ...

Transmitting solely the updated information from the database

I am working on a table that is populated with data from the server using ajax. The table has columns A, B, C, and D where C and D are editable by the user. After the user makes changes to the data in the table, I need to capture only the lines that have b ...

Ways to soften a section of a canvas component?

What is the simplest way to apply a blur effect to a specific portion of my canvas element? I am utilizing the JavaScript 3D Library known as three.js. This library simplifies the use of WebGL. While they offer examples of blur and depth of field effects, ...

Can you explain the process of implementing @media queries in SASS?

I am having some trouble understanding the syntax for media queries in SASS. I attempted to use this particular line of code, but it resulted in an error: @media screen (max-width: 1550px) #server-name left: 80% ...

having trouble transferring the password field in PHP to phpMyAdmin

My HTML form collects the user's first name, last name, username, and password. I am trying to upload this data to my local phpMyAdmin, but I'm facing an issue with storing the password in the database. Below is my HTML code: <input type="te ...

Switch up the button hue as you scroll for a fresh look

Attempting to achieve: CSS change color on scroll / cut text - overflow z-index This code snippet uses the clip property to change the color of a button when scrolling. The goal is to make it change color as you move from the header to the body, but it&apo ...

Tips for organizing visuals in ReactJS using CSS in pairs of two

Utilizing Leaflet maps alongside recharts in a ReactJS environment, I have an issue where the PopUp displaying six charts vertically when clicking on a map marker. My goal is to style these charts into groups of two, arranged in three lines. https://i.sst ...

Collection of numbers with decimal points

Can one use <li> numbers in this format?: 1.1 First Item 1.2 Second Item 2.1 Other item ...

Ways to verify the header (h1, h2, h3) attribute of a DOM element

In JavaScript or jQuery, I have a reference to a link. How can I determine if it is an <h1>, <h2>, or another type of heading element? ...

A step-by-step guide on changing an image

Is it possible to change an image when the user clicks on a link to expand its content? <ul class="accor"> <li> Item 1 <img src="../plus.png"> <p> Lorem ipsum dolor sit amet</p> </li> </ul> $(' ...

Positioning a Form with Sliding Out Effects Using CSS

Hello, I recently came across a tutorial online that helped me create a form slide effect on my website. However, the issue I'm facing is that the form is positioned to the left and I would like it to be placed on the right instead. For reference, h ...

Featuring my Cookie page prominently on my website's homepage

I am facing a simple issue: I have a cookie verification page (cookies_check.php) that I want to include on my home page (accueil.php). So, currently, the only code on accueil.php is: <?php include ('Controleur/cookies_check.php'); ?> He ...

Manipulate container (div) to reveal and conceal

My jQuery was working fine until I added some more divs to my HTML. I'm now trying to toggle the opening and closing of a discussion container named discussionContainer with a click on the button replyButton. Any assistance would be highly appreciated ...

Display issue with sub-menu when hovered over

I've been dedicating time to a project that is almost completed. The one issue that has me stumped is the sub menus not appearing next to the "active menu." Check out this gif demonstrating the problem You can view the website at: www.su.fi Previou ...

Can an ID tag be used to dynamically change CSS content?

Is there a way to extract the IDs from HTML example: id="title1" so it can be used to display content in the CSS. <table class="layout display responsive-table"> <thead> <tr> <th class="th ...