Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:07:35+00:00 2026-05-27T10:07:35+00:00

I can’t find any solution to this problem. Here’s the render I want: http://jsfiddle.net/kQSxb/

  • 0

I can’t find any solution to this problem.

Here’s the render I want:
http://jsfiddle.net/kQSxb/

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
  <div id="wrapper">
    <div id="container">
      <span>Lorem ipsum dolor sit amet,</span>
      <span>consectetur adipisicing elit, sed</span>
      <span>do eiusmod tempor incididunt.</span>
    </div>
  </div>
</body>
</html>

CSS:

#wrapper {
  width: 600px;
  height: 600px;
  background-color: #eeeeee;
  float: left;
}
#container {
  width: 500px;
  margin-top: 30px;
  float: left;
}
#container span {
  background-color: red;
  padding-left: 20px;
  padding-right: 20px;
  font-size: 30px;
  margin-bottom: 3px;
  display: inline-block;
}

Is it possible to have this exact render (paddings left and right for each lines, margin between each lines) with only ONE <span> (or <p>, or <div>) in the <div>#container?

I want to add padding – to the left and to the right – each lines.
So, the words consectetur and do must have left padding, and the words amet, sed (and the dot) must have right padding.

If not, is it possible to do this with CSS3, or maybe with jQuery hack?

Thank you!

ps: sorry guys, I wasn’t clear enough. I’ve edited my post. :-/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:07:36+00:00Added an answer on May 27, 2026 at 10:07 am

    Well, here’s my answer…

    Obviously, it is impossible to do in CSS so we have to find another way to separate each lines.
    A way to do this is to modify a little bit the markup and the stylesheet and parse the string to create a span for each line rendered.

    Ugly code:

    String.prototype.spanify = function(nb_char) {
      var regex = '.{1,'+nb_char+'}(\\s|$)|\\S+?(\\s|$)';
      return '<span>' + this.match(RegExp(regex, 'g')).join('</span><span>') + '</span>';
    };
    
    $.fn.titleize = function() {
      var title = $(this).html();
      var title_calculated = '<span id="title" style="visibility: hidden; position: absolute;">' + title + '</span>';
      $('body').append(title_calculated);
      var width = $(this).html(title).width() - 20;
      var full_width = $('body').find('#title').width();
      $('#title').remove();
      var nb_lines = Math.floor(full_width / width);
      var nb_char_per_line = Math.floor(title.length / nb_lines);
      var new_title = title.spanify(nb_char_per_line);
      $(this).html(new_title);
    }
    $('.title').titleize();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can someone guide me on a possible solution? I don't want to use /bin/cp
Can anyone help me trying to find out why this doesn't work. The brushes
can someone show me the regex for this preg_match. I want to make sure
can any one tell me how can change this java code into objective c.is
can you recommend some good ASP.NET tutorials or a good book? Should I jump
Can a LINQ enabled app run on a machine that only has the .NET
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can anybody shed some light on getDay() in Javascript please. Here datepicker is textbox
Can I run this in a Windows command prompt like I can run it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.