Improving the layout of text by adjusting the width within a flex-box styled card

I have a card with the style property "display: flex;" applied to it along with other stylings, all of which are checked in the snippet below.

My goal is for the text within the card to move to a new line once its width reaches either 120px or 7.5em.

.card{
  width: 269px;
    margin-bottom: 3.5625rem;
    display: flex;
    flex-direction: column;
    /* border: 1px solid rgba(177, 181, 190, 0.28); */
    box-shadow: 0px 0px 0px 1px rgba(177, 181, 190, 0.315);
    border-radius: .5625rem;
    transition: .2s all var(--primary-ease);
}.card:hover{
    box-shadow: 0px 7px 38px 0px #354f4d3b;
}.card:hover .card-title {
    color: var(--primary-light);
}
.card-header{
    background-color: #6484ED;
    padding: 26px 70px;
    border-radius: .5625rem .5625rem 0 0;
}
.card-info{
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    padding: 17px;
}
p.card-title{
    position: static;
    width: 50%;
}
<div class="card">
                    <div class="card-header">
                        <svg width="109" height="109" viewBox="0 0 109 109" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="54.5" cy="54.5" r="54.5" fill="white"/>
</svg>

                        <p class="remove-defaults" style="font-family: Cairo;font-style: normal;font-weight: 600;font-size: 10px;line-height: 19px;color:#fff;">circle</p>
                    </div>
                    <div class="card-info">
                        <p class="card-title strong np">asctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdass</p>
                        <div class="new"></div>
                        <p class="text-xs np">make school fun</p>
                    </div>
                </div>

Answer №1

It seems like the perfect opportunity to utilize the word-break property

.card {
  width: 269px;
  margin-bottom: 3.5625rem;
  display: flex;
  flex-direction: column;
  /* border: 1px solid rgba(177, 181, 190, 0.28); */
  box-shadow: 0px 0px 0px 1px rgba(177, 181, 190, 0.315);
  border-radius: .5625rem;
  transition: .2s all var(--primary-ease);
}

.card:hover {
  box-shadow: 0px 7px 38px 0px #354f4d3b;
}

.card:hover .card-title {
  color: var(--primary-light);
}

.card-header {
  background-color: #6484ED;
  padding: 26px 70px;
  border-radius: .5625rem .5625rem 0 0;
}

.card-info {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  padding: 17px;
}

p.card-title {
  position: static;
  width: 50%;
  word-break: break-word;
}
<div class="card">
  <div class="card-header">
    <svg width="109" height="109" viewBox="0 0 109 109" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="54.5" cy="54.5" r="54.5" fill="white"/>
</svg>

    <p class="remove-defaults" style="font-family: Cairo;font-style: normal;font-weight: 600;font-size: 10px;line-height: 19px;color:#fff;">circle</p>
  </div>
  <div class="card-info">
    <p class="card-title strong np">asctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassdasctaasdassdassascasaaaasdassdassd</p>
    <div class="new"></div>
    <p class="text-xs np">web education</p>
  </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

Unable to generate a navigation panel using HTML/CSS and jQuery

I recently completed the basic courses in HTML/CSS, JavaScript, jQuery, and PHP on Codecademy. I'm currently working on creating a website using HTML/CSS and jQuery in Codecademy's codebits. However, I'm facing some issues with my navigation ...

Placing a horizontal line or Material UI Divider at the bottom of a webpage

Working with react and material ui, I am facing an issue in positioning a divider close to the bottom of the webpage along with a logo. In my jsx file, I have a functional component utilizing material UI drawer on the left side of the browser, where I have ...

Set up a mouseover function for a <datalist> tag

Currently, I am delving into the world of javascript/jquery and I have set up an input field with a datalist. However, I am encountering a slight hurdle - I am unable to trigger an event when hovering over the datalist once it appears. Although I have man ...

Challenges with creating a contact form using bootstrap modal

I'm facing an issue with a bootstrap modal contact form. It works fine on all browsers except for iPad/Safari. Can anyone help me figure out what's wrong? On iPad, the modal is positioned to the right and down the page instead of in the cente ...

When two elements overlap, adjust their CSS positions to ensure responsiveness

Is there a way to adjust the position of an element when it comes into contact with another? Check out this example http://jsfiddle.net/mZYR8/1/ In the example, if .title-wrap (yellow) touches .right-wrap (orange), I want the orange element to slide unde ...

Activate the overflow feature within native-base cards

I have a unique design element on a website that showcases an image overflowing off a card. The image has a negative margin-top of -50, creating this effect. Now I'm trying to replicate this design in react-native using native-base components. Here i ...

Creating a card design that responds to user interactions using CSS and HTML

I attempted to create a responsive queue of playing cards that adjusts based on the display width. I want this queue to perfectly fit the display width so that no card is cut off. It should be optimized for phones, tablets, and desktop screens. Additiona ...

placing an empty gap within a visual depiction

My gallery lightbox displays images along with descriptions. However, the descriptions are all showing up in the same line with the same style and color. I want to separate each description on a new line to give some space. Here's an example of how th ...

Ensure that the spacing between rows matches the spacing between columns

I am working on creating a 3x3 grid using Bootstrap. My goal is to have consistent spacing between the rows and columns. How can I achieve this effectively? ...

What are some ways to design scrollbars with a Google Wave-like style?

Is there a way to design scrollbars similar to the ones found in Google Wave? They seem to save space and have an appealing look. I am interested in implementing these customized scrollbars on a div element, just like how Google Wave utilizes them. https: ...

Is it necessary to mark all checkboxes in the initial column of the gridview?

I have encountered an issue with my code that checks all checkboxes in the first column of a gridview. It seems to work only for Internet Explorer versions 5.0 to 8.0, but gives a Javascript error when running on IE 9 and above stating "Function Expected ...

Resizing a damaged HTML table to fit within a designated width using CSS

Here is a challenge - I have some broken HTML that I can't touch, and don't want to use JavaScript to fix. My goal is to make it fit within a specific width: http://jsfiddle.net/P7A9m/2/ <div id="main"> <table> <tr> ...

Tips for creating a cohesive group of HTML elements within an editable area

Imagine having a contenteditable area with some existing content: <div contenteditable="true"> <p>first paragraph</p> <p> <img width='63' src='https://developer.cdn.mozilla.net/media/img/mdn-logo-s ...

Using a DIV to contain a FileUpload Control in an ASPX page

Scenario: I have an ASPX page (Page A) without a form element, which contains a DIV displaying another ASPX page (Page B) with a FileUpload Control inside a form element. Requirement: Submit the form to upload the file without refreshing or navigating awa ...

Dropdown menu is not positioning correctly over other elements on the webpage

After researching multiple stack overflow questions and attempting various solutions, I still haven't been able to resolve my issue. Please refrain from marking this question as a duplicate. The problem I am facing is that my dropdown menu is not ap ...

Is there a way to customize the font size of Material UI Autocomplete?

I'm currently trying to customize the Material UI Autocomplete component with my own CSS. Specifically, I aim to adjust the font size of the input field. Below is my current implementation: <Autocomplete style={{ width: 200, height: 60, ...

Position a div in the center of the page horizontally

Can someone help me with aligning the #main div in the center of the page? I have this code snippet: <div id="main" style=" margin:0 auto; "> <div style="float: left"> <a style="display: block" href="#"><img src="test.gif" ...

The submenu is not aligned directly under its parent item

The sub-menu is not appearing below the parent item as expected. I have tried removing and adding the 'absolute' property, but it doesn't seem to have any effect. Check out the JS Fiddle for reference: http://jsfiddle.net/42qg5/ HTML Code ...

What is the best way to retrieve Select button values from a MySQL database and pass them to a different page?

I've been trying to code it, but I keep running into issues. The main objective was to allow the user to select a value from a MySQLi database and then send that value to another page. I know people recommend using AJAX for this purpose, so I attempte ...

Why are my elements not appearing where I want them to in absolute positioning?

Could use some help with a seemingly simple question, I just need some clarity on this issue. Background: I am working on developing a complex website and one of my ideas involves generating a series of boxes on the screen. For various reasons that are t ...