Styling a playbook using CSS Grid management techniques

Exciting to create a playbook layout style, here's how it goes:

       Name: Text starting here - unique style #1
             text that moves to a new line with a different look - unique style #2
             more text continuing on another new line - unique style #1

Longer Name: Text starting here - unique style #1
             text that moves to a new line with a different look - unique style #2
             more text continuing on another new line - unique style #1

The challenge lies in getting the style #2 text to start on a new line.

This is the code I'm using:

<div class="line">
  <div class="level1">
    <div class="name" >name:</div> 
      Text starting here - unique style #1 
      <span>text which should go in a new line with different style #2</span> 
      text continue here with another new line - unique style #1
    </div>
  </div>

<style type="text/css">
.line {
    text-align: right;
    font-size: 14px;
    width: 477px;
    margin: 0 auto;


}

.level1 {
    display: inline-flex;
    font-size: 14px;
    line-height: 12px;


}

.name {
    display: inline-block;
    font-size: 14px;
    width: 40px;
    min-width: 50px;
    text-align: left;
    margin-left: 15px;


}

</style>

Despite setting these values, Style #2 always breaks into a new column rather than a new line. You can view an example on jsfiddle. It seems like "flex-inline" might be causing this issue. Are there any alternatives for this?

Answer №1

Use this snippet for assistance.

<div class="section">
    <div class="block1">
        <label class="title" >Title:</label> 
        <p>
            Start of the text - style A <br>
            Text to be displayed on a new line with style B <br>s
            Continue text here with a different line - style A
        </p>
    </div>
</div>

<style type="text/css">
.section {
    font-size: 14px;
    width: 477px;
    margin: 0 auto;
}

.block1 {
    display: inline-flex;
    font-size: 14px;
    line-height: 12px;
}

.title {
    display: inline-block;
    font-size: 14px;
    width: 40px;
    min-width: 50px;
    text-align: left;
    margin-left: 15px;
}
</style>

Answer №2

To ensure your elements are aligned to the right, consider implementing the following code snippet. Keep in mind that you may need to adjust for various screen sizes.

*,
*:after,
*:before {
  margin: 0;
  padding: 0;
  box-sizing: 0;
}

.main {
  margin: 1px;
  border: 1px solid;
  padding: 10px;
  display: inline-block;
}

section {
  margin-bottom: 5px;
  text-align: right;
  border: 1px solid red;
  padding: 10px;
}

section>.name {
  border: 1px solid;
  padding: 5px;
  display: inline-block;
  vertical-align: top;
}

section>.content {
  border: 1px solid;
  padding: 5px;
  max-width: 100%;
  display: inline-block;
  text-align: left;
}
<div class="main">
  <section>
    <div class="name"> name:</div>
    <div class="content">
      <p>Text starting here - style #1 </p>
      <p>text which should go in a new line with different style #2</p>
      <p>text continue here with another new line - style #1</p>
    </div>
  </section>
  <section>
    <div class="name">Longer name:</div>
    <div class="content">
      <p>Text starting here - style #1 </p>
      <p>text which should go in a new line with different style #2</p>
      <p>text continue here with another new line - style #1</p>
    </div>
  </section>
  <section>
    <div class="name">Much Longer name:</div>
    <div class="content">
      <p>Text starting here - style #1 </p>
      <p>text which should go in a new line with different style #2</p>
      <p>text continue here with another new line - style #1</p>
      <p>text continue here with another new line - style #1</p>
      <p>text continue here with another new line - style #1</p>
    </div>
  </section>
  <section>
    <div class="name">A really Longer name:</div>
    <div class="content">
      <p>Text starting here - style #1 </p>
      <p>text which should go in a new line with different style #2</p>
      <p>text continue here with another new line - style #1</p>
    </div>
  </section>
</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

Is Flash now irrelevant? What makes HTML5 or CSS3 so powerful?

While I may not consider myself a dedicated Flash Activist, it's hard to ignore the fact that despite its flaws, there are some important uses for it on certain websites. However, with all the buzz around HTML5 and CSS3 being the future of the web, ev ...

Animating numerous elements simultaneously during Vue component rendering

Take a look at this simple case in the following jsfiddle: https://jsfiddle.net/hsak2rdu/ I attempted to swap and animate two elements, but it didn't work as expected. When you click the toggle button in the playground, the second element quickly mo ...

Using a combination of AND and OR in XPATH

Recently, I encountered the following HTML code: <div><h6>abc/h6><p>date</p></div> Using Selenium, I managed to locate this element based on text. However, the issue arises when <h6> can contain various words like "d ...

Is it possible to submit a select menu without using a submit button within a loop?

I'm having an issue with my code that submits a form when an option in a select box is clicked. The problem arises when I try to put it inside a loop, as it stops working. Can anyone assist me with this? Below is the code snippet causing trouble: &l ...

Tips for successfully implementing overflow-x in a timeline layout without causing any format disruptions

I've been working on a dynamic timeline design that adapts to different screen sizes. I applied overflow-x property to prevent horizontal scrolling in the mobile version, making the burger menu's sub-items visible without requiring a click. Howev ...

Placing a new item following the child of a different element

How can I use jQuery to add a div inside id123 after sth2, but only for one specific occurrence? I understand how to do it after every sth2, but not just once. <div class="id123"> <div class="a"></div> .. <div class="sth1">< ...

Is there a way to modify this JavaScript code so that it can function with a

I have developed a unique audio player that plays random sections of different songs. Currently, it is hardcoded for one song with three intros, a midsection, and three outros. I am looking to create a system where a list of songs can be randomly chosen fr ...

I'm having trouble viewing my display:table-cell content because Internet Explorer is hiding it

I am attempting to align an icon vertically centered and far right inside a container. I currently have code that achieves this using ::after and table-cell properties. However, the content does not display in Internet Explorer. If I remove the display:tab ...

There appears to be an issue with reading the property 'toLowerCase' of an undefined element, and I'm having trouble identifying the error

The variables I have initialized (globally): var audio; var LANGUAGE; var audioArray; var MEDIAARRAY; var WORDS; var SOUNDARRAY; This specific line is causing the error: var audioId = MEDIAARRAY.audio.lowercase.indexOf(exObject['exerciseGetWordInpu ...

Having issues with the functionality of the jQuery HTML function

I'm working on this jQuery code snippet: $('#wrapper').html('<img src="/loading.gif">'); var formdata = $("#validateuserform").serialize(); $.post("/userformdata.php",formdata,function(html){ if(html) ...

Discover the secret to incorporating concealed text in WordPress with a hidden div through the power of JavaScript

For a while now, I've been trying to implement a functionality where clicking on a text reveals a dropdown menu with more information, similar to a "read more" feature. I have limited experience in Java or jQuery, and I can't figure out if the i ...

The CSS command for displaying additional content is not functioning within table elements

I'm attempting to add a 'read more' arrow to the third column, which should expand the text in the first column when clicked. I have the following code, and it works fine outside of a table but not inside one. Where am I going wrong? I prefe ...

Is the text alignment off?

I've been immersed in creating a website, but I encountered an issue for which I can't seem to find the solution. Check out my text alignment here (test) - it's not aligned all the way to the left of the content Here is the HTML code: < ...

Central Player Component

Do you need help with centering text and a player on your WP site? Check out my website Here is the code I am currently using: <div class="listen_section"> <div class="container"> <div class="row"> <div class ...

Whenever I nest my div tags within another div element in an HTML document

Whenever I try to position a div inside another div using float, I encounter problems. <div id="main"> <div id="anotherDiv"> <h1>Test</h1> </div> </div> Here is the corresponding style sheet: #main{ ba ...

Looking to display the ng-option in two lines within Angular 6?

How can I display data in a select dropdown with two lines for each option? I am currently using ng-select. <ng-select [(ngModel)]="selectedData" placeholder="Select Data"> <div *ngFor="let data of Data"> <ng-option [value]="da ...

The positioning of the <thead> element does not seem to be functioning properly

I attempted to create a background for the header (thead) using a pseudo element (:after) because I wanted the background to span from one edge to another edge (including both left and right side padding). However, thead is not taking a relative position a ...

Looking for assistance with my website's navigation bar and logo

Looking for assistance in moving my navigation buttons to each side of the logo. As a beginner in web design and CSS, I've been struggling with this task. Essentially, I want the "home" and "about" buttons on the left side of the logo, 16px apart from ...

The thickness of an SVG line increases as it is rotated

I am working with multiple straight lines and have specified the stroke-width as 4. However, when I attempt to rotate them, the lines appear thicker than expected. Additionally, setting a negative value, such as <path d="M0 -10 20 0" stroke-width="4" st ...

Looking for a smart way to extract all the selected elements from a form?

I am attempting to retrieve all the checked items from this form using JavaScript. I have looked at previous solutions, but none of them fit my requirements. <form id="checkform" class="container" style="margin-top:20px;"> <input type="checkb ...