开发者

Why does my text has the justify effect when I didnt made it to have this effect (css/php)

开发者 https://www.devze.com 2022-12-26 02:44 出处:网络
Why my text has the justify effect? In my whole site, I make echos and i dont specify a \"text-align:justify;\"

Why my text has the justify effect? In my whole site, I make echos and i dont specify a "text-align:justify;" but my text is still justifying. Justify is when you make the browser window smaller, the text moves so it fits in the window. I tryed making something like this: <?php echo "<h1>some stuff.</h1>"; ?> <html> <head> <style> h1 { text-align:center; } etc....

but it just makes the text go in the center and it keeps the justify effect.

开发者_如何学编程

please help me =[ thanks


Justify is when you make the browser window smaller, the text moves so it fits in the window.

That's not what justify is. Justify makes it so all lines of text are the same width, like this:

Why does my text has the justify effect when I didnt made it to have this effect (css/php)


(source: pws-ltd.com)

If you don't want the text to stay inside the window when you shrink it (so if you want a horizontal scrollbar), you have to set a min-width on a <div> containing the text.

Edit: though maybe I misunderstood what you were actually trying to do, and you just want it centered. If so, use margin: 0 auto; not text-align: center;


Justifying is when the spacing between the words is adjusted so text is fully aligned on both the left and the right of the block of text.

What you are describing sounds like even though you want the text centered, it is long enough to fill the page and thus doesn't really look centered. Consider adding something like this. The fixed width keeps the text from filling the window, and the margin: 0 auto centers the h1 tag itself:

<style type="text/css">
    h1 { text-align: center; width: 300px; margin: 0 auto }
</style>
0

精彩评论

暂无评论...
验证码 换一张
取 消