Tips for separating these two words onto two separate lines

I created this box using Angular Material, but I am having trouble breaking the words "1349" and "New Feedback" into two lines. Here's an image included in my design. Any tips on accomplishing this in Angular Material? Thank you!

 <style>
    .box-item {
        background-color: cornflowerblue;
        width: 100px;
        height: 120px;
    }
    .box-text {
        color:white;
    }
</style> 

   <div layout="row" style="padding: 32px;" ng-cloak>

<md-whiteframe class="md-whiteframe-2dp box-item" md-colors="[enter image description here][1]background:'blue-400'}"
               flex-sm="45" flex-gt-sm="35" flex-gt-md="25" layout
               layout-align="end center" layout-margin>
    <span class="md-display-1 box-text">1349</span>
    <span class="box-text">New Feedbacks</span>
</md-whiteframe>
</div>

Answer №1

It appears this is a query related to CSS.

To align two inline elements (spans) on separate lines, consider styling one as a block element or inserting a br tag between them.

<style>
  .box-item {
      display: inline-block;
      background-color: cornflowerblue;
      height: 120px;
  }
  .box-text {
      color:white;
      display: block;
  }
</style>

Refer to this example link.

Answer №2

One reason for this issue is that the <span> tag is inherently an inline element, meaning it only occupies as much space as needed.

If you find yourself needing to display items on separate lines using a span element, you have a few options. You can adjust the element with CSS by changing its display property to block, insert a line break between elements using the <br> tag, or utilize a block-level element such as the <div> tag.

The recommended approach is to choose the appropriate HTML element for the purpose. For example, opting for a block-level tag like the <div> tag ensures that both elements take up the full width available and appear on separate lines without the need for additional CSS code (saving valuable bytes in your HTML).

Below is how you can achieve this in CSS:

.box-text {
    color:white;
    display: block;
}

Alternatively, here is an example utilizing the <br> tag:

<span class="md-display-1 box-text">1349</span>
<br>
<span class="box-text">New Feedbacks</span>

The simplest and most semantic solution of all three methods would be to use div tags:

<div class="md-display-1 box-text">1349</div>
<div class="box-text">New Feedbacks</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

What is the best way to contain my content within a bordered box?

As a beginner in HTML and CSS, I have successfully created a basic website with a simple menu at the top that includes links to different pages like "Home," "About," and "Contact." The website will mainly feature information and images, but I believe it wo ...

Four-region selection box

Is there a way to create a quad state checkbox without using a set of images for various icons? I know how to have a tri-state checkbox with indeterminate, but I need to rotate through 4 states. Are there any more elegant solutions available? ...

Having trouble with playing an mp4 video from Amazon S3 in an HTML video tag?

I have uploaded a video to S3 from my Android device, but it is not playing properly in HTML on Chrome. Here is the link to the video: ...

Encountering a problem with AJAX displaying error code 80020101 while attempting to retrieve a string from a

I encountered an error while running my code: Microsoft JScript runtime error: Could not complete the operation due to error 80020101. I came across this thread on Stackoverflow that talks about a similar issue: Ajax request problem: error 80020101 var d ...

How to use PHP for setting up a MySQL database?

Currently, I am immersing myself in the world of PHP and MySQL. I decided to take a shot at creating a basic HTML form along with a PHP script to set up a MySQL database. Unfortunately, when I tried to test it out, things didn't go as planned. Upon su ...

The lines intersecting with the ethereal image in the background

I'm trying to achieve button links with an image overlay, but so far I've only been able to do it using CSS: section a:link, section a:visited { width: 150px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: ...

Halt hovering effect after a set duration using CSS or Vanilla JavaScript

Looking for a way to create a hover effect that lasts for a specific duration before stopping. I want the background to appear for just 1 second, even if the mouse remains hovering. Preferably using CSS or JavaScript only, without jQuery. To see my curren ...

Determine if an HTML element contains a specific class using JavaScript

Is there a simple method to determine if an HTML element possesses a particular class? For instance: var item = document.getElementById('something'); if (item.classList.contains('car')) Remember, an element can have more than one clas ...

The dynamic change of a required field property does not occur

I am facing an issue where one of my fields in the form should be mandatory or not based on a boolean variable. Even if the variable changes, the field always remains required. I'm puzzled about why my expressionProperties templateOptions.required is ...

Animate the centering of a DIV

Currently, I am working on an animation featuring a series of DIV's contained within a div with the identifier id="wrapper", all styled using CSS3. However, when I hover over the rounded box, the animation is not properly aligned in the center. You ca ...

Loading content from external sources on the dashboard

I'm trying to figure out how to load an external URL () within the content of a Dashboard. My current code looks like this: .state('app.urlloading', { url: '/url-loading', controller:function($window){ $window.locat ...

What is the best way to retrieve the unique identifier of dynamically created divs and showcase a message based on that identifier?

Is it possible to retrieve the id of a dynamically generated div and show a unique message when each div is clicked in the code snippet found at this link? function get_random_color() { var letters = '0123456789ABCDEF'.split(''); ...

Stop hyperlinks from automatically opening in a new tab or window

I'm having trouble with my website links opening in new tabs. Even after changing the attributes to _self, it still doesn't work. Can someone please review my code below and provide a solution? Feel free to ask for more clarification if needed. ...

Error: Java Applet cannot be found

As I've come to understand, Java applets are no longer widely used and supported by most browsers. Could it be that my issue is simply due to lack of support? I'm currently testing my HTML file using Internet Explorer on Windows 10 with the follo ...

Javascript callback function cannot access variables from its parent function

As a Javascript newbie, I am currently diving into callbacks for my project. The goal is to retrieve address input from multiple text boxes on the HTML side and then execute core functionalities upon button click. There are N text boxes, each containing an ...

Programmatically close a modal dialog using a $http promise

Utilizing AngularJS with Bootstrap UI, I have implemented a modal dialog to display while an HTTP request is processing. This serves as a wait dialog and can be easily inserted into different parts of the code like so: $scope.foobar = function() { var wa ...

Use jQuery to gather all the values from an HTML select element

I am using PHP to generate a HTML select option based on folders in a directory. Now, I am looking for a way to retrieve the value of the selected option in my jQuery script. I am familiar with $('#select :selected').text() and $(#select).val(), ...

An illustration of a skeleton alongside written content in neighboring sections

I am relatively new to CSS and came across an issue with Skeleton when resizing the browser window. I have an image and text displayed next to each other in columns, as shown below (although there is much more text in reality). Everything looks fine initia ...

Angular Material Progress Spinner is static and not animated

I've been attempting to incorporate an indeterminate spinner from Angular Material. After reviewing the stack blitz example provided on their official website https://stackblitz.com/angular/nkabnxaenep, I carefully compared the package jsons and could ...

When hovering over it, an element within an li tag appears larger than its parent element

I'm currently working on a project for my school classes and running into an issue with CSS. I'm trying to enclose everything in boxes, but it's proving to be quite challenging. The main problem I'm facing is that when I hover over the ...