What is the best way to duplicate this content from a picture using CSS?

Trying to replicate text in an image using HTML and CSS. Wondering if there's a better way than setting each line with its own font size.

Here's the image I'm working on:
https://i.sstatic.net/bMPhy.png

Current issues with the approach:

  • Not responsive on different screen sizes
  • Some lines are uneven in length

Any suggestions for a proper solution?

.big-text {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: bold;
  text-justify: inter-character;
  font-size: 5rem;
  line-height: 100%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"/>

<div class="col-md-4 big-text">
  <span>FIREWORK</span>
  <span style="font-size: 7rem;">&amp; PYRO</span>
  <span style="color: #fd0227; font-size: 8rem;">FIRING</span>
  <span style="font-size: 5.6rem;">SYSTEMS</span>
</div>

Answer №1

Give this SVG a shot

<svg viewBox="0 0 200 80" xmlns="http://www.w3.org/2000/svg">
  <text y="20" font-size="0.95em">EXPLOSION</text>
  <text y="40" font-size="1.45em">&BLAST</text>
  <text y="60" fill="orange" font-size="1.5em">IGNITION</text>
  <text y="75" font-size="1.1em">MECHANISMS</text>
</svg>

Answer №2

Take a look at this example below, designed for a single display, ideally for the web. If you need to expand it, you can use media queries to adjust for mobile and web devices.

<div class="image-text">
 <p>Firework</p>
 <p class="text-red">& PYRO</p>
 <p>Firing</p>
 <p>Systems</p>
</div>

.image-text p{
   padding:0;
   margin:0;
   font-size:28px;
   font-weight:bold;
   letter-spacing:1.2px
  }

.image-text p:nth-of-type(3){
  font-size:42px
 }

.image-text p:nth-of-type(4){
  font-size:32px
 }

.text-red{
  color:red
 }

Visit this CodePen for a live demo: Link Here

Answer №3

To stack your span elements, you can utilize display:block.

Alternatively, you may opt for a smaller line-height and margin to maintain consistent spacing between lines of spans. Using font-size calculated from a combination of px and vw values can also be beneficial.

Demonstration screenshot and concept are shown below:

https://i.sstatic.net/17GI9.jpg

.big-text {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: bold;
  text-justify: inter-character;
  font-size:calc(12px + 2.45vw);
  line-height: 0.7;
  background:gray;/*see me for debug*/

}

.big-text>span {
  display: block;
  width:max-content;
  margin:8px auto ;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
<div class="container">
  <div class="row">
    <div class="col-md-4 big-text">
      <span>FIREWORK</span>
      <span style="font-size:1.45em">&amp; PYRO</span>
      <span style="color: #fd0227; font-size: 1.65em">FIRING</span>
      <span style="font-size:1.17em;">SYSTEMS</span>
    </div>
  </div>
</div>

Media queries can also be utilized to resize text and modify layout. An example of using media queries to set the first span sideways on larger screens is provided below. View the demo here: https://codepen.io/gc-nomade/pen/abNKbyP or see snippet below.

https://i.sstatic.net/O9zqZ.jpg

.big-text {
  font-family: "Roboto Condensed", sans-serif;
  font-weight: bold;
  text-justify: inter-character;
  font-size: calc(12px + 2.45vw);
  line-height: 0.7;
  background: gray;
  /*see me for debug*/
}

.big-text>span {
  display: block;
  width: max-content;
  margin: 8px auto;
  white-space: nowrap;
}

@media screen and (min-width: 769px) {
  .vertical-md {
    writing-mode: vertical-rl;
    transform: scale(-1);
    font-size: 0.615em;
    color:#fd0227;
    -webkit-text-stroke:1px #fff
  }
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
<div class="container">
  <div class="row">
    <div class="col-md-4 big-text">
      <span class="float-md-left vertical-md">FIREWORK</span>
      <span style="font-size:1.45em">&amp; PYRO</span>
      <span style="color: #fd0227; font-size: 1.65em">FIRING</span>
      <span style="font-size:1.17em;">SYSTEMS</span>
    </div>
  </div>
</div>

Answer №4

Not every problem comes with an elegant solution, and this seems to be one of them. Each line requires its own font size adjustment, either through inline styling or CSS, which can result in code that is less than pleasing to the eye.

However, if you avoid line wrapping, the design scales nicely with the use of rem units. Experiment with adjusting the font-size in the :root to see the effect for yourself.

:root {
  font-size: 15px;
}

.big-text {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: bold;
  text-justify: inter-word;
  font-size: 5rem;
  line-height: 100%;
}

.big-text span {
  white-space: nowrap;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<div class="col-md-4 big-text">
  <span>FIREWORK</span>
  <span style="font-size: 7rem;">&amp; PYRO</span>
  <span style="color: #fd0227; font-size: 8rem;">FIRING</span>
  <span style="font-size: 5.6rem;">SYSTEMS</span>
</div>

Answer №5

Creating beautiful text effects with SVG is simple.

By using the textLength attribute and setting it to 100%, you can achieve justified text with dynamic letter spacing adjustments.

Additionally, the x and y attributes allow precise positioning of the text on the SVG canvas.

To control the viewport position and dimensions, utilize the viewBox attribute in your SVG code.

Learn more about text in SVG here.

html,body,svg { height:100% }
<!-- Check out this SVG text code example on MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text -->

<svg viewBox="0 0 140 150" xmlns="http://www.w3.org/2000/svg">
  <style>
    .small { font: italic 13px sans-serif; }
    .heavy { font: bold 30px sans-serif; }
  
    /* Customize text color with fill property in SVG */
    .system { font: italic 40px serif; fill: red; }
  </style>

  <text textLength="100%" x="0" y="10" class="small">Firework</text>
  <text textLength="100%" x="0" y="32" class="heavy">& PYRO</text>
  <text textLength="100%" x="0" y="43" class="small">FIRING</text>
  <text textLength="100%" x="0" y="72" class="system">SYSTEM</text>
  
</svg>

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 it possible to incorporate a 960 grid system into a div container?

Can I contain an entire 960 grid within a div on my webpage? I am looking to create a page wider than 960px, and considering placing sidebars outside of the 960 grid while having it manage the central column. ...

Is the ID "nodeName" specifically designated as reserved in the HTML5 language specifications?

I have an element with the following id: <span id="nodeName"></span> In my HTML code. Then, when using jQuery to do the following: $("#nodeName").html("someString"); I am getting an error in the console that says: Uncaught TypeError: Objec ...

Implementing grid items in CSS Grid that do not stretch the grid row and have a container that is scrollable

Here is my dilemma: I am looking to create a grid with a fixed number of columns (that can be adjusted via javascript) and a variable number of rows, all with equal heights. The rows will be determined by the number of grid items, which are represented a ...

Is there a way to customize the default Bootstrap accordion button?

Looking for assistance on how to customize the default collapse button for Bootstrap 4 or 5 accordion using fontawesome icons. Can anyone help with this? Thanks in advance! Here is an example of an accordion: <div class="accordion" id="a ...

Retrieve dynamic data from a website using jQuery's AJAX functionality

I am trying to retrieve the data from example.com/page.html. When I view the content of page.html using Chrome Browser, it looks like this: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> & ...

How can I validate HTML input elements within a DIV (a visible wizard step) situated within a FORM?

I recently made a decision to develop a wizard form using HTML 5 (specifically ASP.NET MVC). Below is the structure of my HTML form: @using (Html.BeginForm()) { <div class="wizard-step"> <input type="text" name="firstname" placeholder ...

Tables inserted via ckeditor do not preserve the style attribute

After incorporating ckeditor into my web page along with the table plugin, I noticed that sometimes the width of tables created in the editor window extends beyond the boundaries of the webpage when displayed. To address this issue, I made some adjustments ...

In an HTML document, you may encounter whitespace that is not present in JSFiddle

Upon running this HTML file in my browser, I noticed that there is an 18px gap at the top of the first div. It's strange because this issue only occurs when I run the HTML locally on my browser, but everything works fine on JSFiddle. I'm puzzled ...

When the window is resized, the div containing a table is getting pushed beyond its original

I have been developing a 'calculadora de creditos' or credits calculator. For this project, I used a responsive layout. Despite searching extensively online for solutions to my issue, I came up empty-handed. CSS CODE: (CSS code here) HTML CO ...

What is the most effective way to determine which radio button is currently selected in a group with the same name using JQuery?

<form class="responses"> <input type="radio" name="option" value="0">False</input> <input type="radio" name="option" value="1">True</input> </form> Just tested: $('[name="option"]').is(':checked ...

Using jQuery to eliminate the 'disabled' attribute from CSS

After using the .val() method to enter data into a text box, I noticed that when trying to click "add", the button appears disabled. <input class="btn-primary action-submit" type="submit" value="Add" disabled=""> If I manually type in text, the dis ...

The sticky HTML table header feature is functional, however, the header's border disappears while scrolling

Utilizing the react-bootstrap-table2 library in my React project, I added custom CSS to create a sticky top row effect: .table-container { overflow-y: auto; max-height: 500px; } .react-bootstrap-table th { position: sticky; top: -1px; background- ...

Struggling to achieve success in redirecting with passport for Facebook

For a "todolist" web application that utilizes passport-facebook for third party authentication, the following code is implemented: passport.use(new FacebookStrategy({ clientID: '566950043453498', clientSecret: '555022a61da40afc8ead59 ...

Can you include an optional selector in SASS?

Here is an interesting concept: adding a CSS-selector optionally to the existing selector stack within a mixin. This is what I envision: @mixin myMixin(mobileSelector:true) { @if(mobileSelector) { .foo .mobile:before, } .classXY .subclass:before ...

Display the GIF when the mouse hovers over it, but ensure it plays just a single time

Is it possible to make a GIF only play once when you hover over it on a website? I want to avoid the animation repeating if the user hovers over it again without refreshing the page. Currently, I have a static image that changes to a gif on mouseover, but ...

Creating a unique dimming effect for modals in a React application

Could someone assist me in adding opacity or dimming the background while a modal is open using the code provided? You can view the working example here. ...

Issue with JQuery: Inability to deactivate an element after receiving an Ajax response

My dynamic dialogue box, generated via Ajax return, presents a challenge involving the dynamically changing drop-down list element $('#functionSelect'). I require this list to trigger disabling of input fields within the dialogue box upon changes ...

Issues with Jquery Div sliding transitions from right to left are not functioning correctly

Creating page transitions in jQuery similar to "http://support.microsoft.com/." Encountering an issue where after the page transitions are completed, they start from the left instead of the expected right direction. Referencing this fiddle (Working Code) ...

React beautiful dnd and Material UI list encountering compatibility problem

I recently encountered an issue while using react beautiful dnd to create a rearrangeable Material UI List. Everything was working correctly, except for the ListItemSecondaryAction within the list. When dragging a list item, the ListItemText and ListItemIc ...

Having trouble integrating a Bootstrap-based ecommerce theme into an Angular8 project?

I have a bootstrap-based ecommerce theme with all the necessary files. The HTML theme is loading perfectly. Check out the official theme page I am integrating into my angular8 project: Theme Page Link I have created a repository for my angular8 project ...