Jump to content

[css] duvida em texto


tintim_22

Recommended Posts

podes usar javascript ...

exemplo com jquery

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
   <script type="text/javascript">
     $(document).ready(function() {
       $('.paragraph').each(function () {
         var p = $(this).children("p");
         var chr = p.html().substr(0, 1);
         var letter = $(this).children("div");

         p.html(p.html().substr(1));
         letter.html(chr);
       });
     });
   </script>
 </head>
 <body>
   <div class="paragraph" style="width: 200px;">
     <div class="first_letter" style="float: left; font-size: 40px; color: red;"></div>
     <p>texto a ser apresentado, texto a ser apresentado, texto a ser apresentado, texto a ser apresentado, texto a ser apresentado, texto a ser apresentado</p>
   </div>
   <div class="paragraph" style="width: 200px;">
     <div class="first_letter" style="float: left; font-size: 40px; color: red;"></div>
     <p>texto a ser apresentado, texto a ser apresentado, texto a ser apresentado, texto a ser apresentado, texto a ser apresentado, texto a ser apresentado</p>
   </div>
 </body>
</html>
IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

Tens que dar um estilo ao pseudo-elemento first-letter do parágrafo. Cuidado, que nem todos os browsers se comportam da mesma forma; testa.

p:first-letter {
float: left;
font-weight: 300%;
// não esquecer de ajustar margin e line-height
}
Edited by mjamado

"Para desenhar um website, não tenho que saber distinguir server-side de client-side" - um membro do fórum que se auto-intitula webdesigner. Temo pelo futuro da web.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.