Reply
How to give a <p> a background like this?
Old 03-09-2010, 12:51 PM How to give a <p> a background like this?
pealo86's Avatar
Webmaster Talker

Posts: 725
Name: Matt
Location: England, north west
Trades: 0
Here's part of a design I made:



Notice how the blue background of the paragraph is jagged at on the right edges.

I thought I'd be able to acheive this using something like:

Code:
p {
    display:inline;
}
Aswell as setting the background and other styles etc. But unfortunately it doesn't work! I tried floating it too but no luck.

Is it possible to do this with CSS? I was sure I'd managed it one point in the past.

Last edited by pealo86; 03-09-2010 at 12:52 PM..
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
When You Register, These Ads Go Away!
Old 03-09-2010, 01:10 PM Re: How to give a <p> a background like this?
c69
c69's Avatar
Experienced Talker

Posts: 35
Name: Constantine
Trades: 0
Its almost impossible to do in css, unless you split each line into individual p.
And / or use many hacks.

here is a huge article on topic, but sorry its in russian:
http://chikuyonok.ru/2010/01/uniform-text-background/
c69 is offline
Reply With Quote
View Public Profile Visit c69's homepage!
 
Old 03-09-2010, 01:13 PM Re: How to give a <p> a background like this?
chrishirst's Avatar
Super Moderator

Posts: 31,018
Location: Blackpool. UK
Trades: 0
without testing;

each line of text would have to be in a separate inline element to give the "jagged" effect.
And the background colour applied to the text holder element.

I wonder if there is a way to do a bit of DOM "jiggery pokery" to handle that? Could be a interesting time waster experiment.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Code Samples | Crowded Nightclub? | Random Ramblings
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-09-2010, 01:52 PM Re: How to give a <p> a background like this?
angele803's Avatar
Perfectly Imperfect

Posts: 1,775
Name: Stephanie
Location: Oklahoma
Trades: 2
I think this article will help you: http://css-tricks.com/text-blocks-over-image/
__________________
Webmaster-Talk Rules
angele803 is offline
Reply With Quote
View Public Profile
 
Old 03-09-2010, 02:20 PM Re: How to give a <p> a background like this?
pealo86's Avatar
Webmaster Talker

Posts: 725
Name: Matt
Location: England, north west
Trades: 0
Great thanks for the help
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 03-09-2010, 02:47 PM Re: How to give a <p> a background like this?
chrishirst's Avatar
Super Moderator

Posts: 31,018
Location: Blackpool. UK
Trades: 0
Bit of javascript "jiggery pokery" and there you go

http://www.modtalk.co.uk/_site/code/...ed-background/

Code:
function wordHighlight(parent) {
	e = document.getElementById(parent);
	var words = e.innerHTML.split(" ");
	
	var outstr = "";
	for (x=0;x<words.length; x++) {
		outstr = outstr + '<span>' + words[x] + ' </span>';
	}
	document.getElementById(parent).innerHTML = outstr;
	
}
CSS code
HTML Code:
#pholder {
	width:50%;
	border:1px solid grey;
	margin:0 auto;
}
#pholder span {
	background-color:blue;
	color:#ffffff;
	opacity:0.5;
	filter:alpha(opacity=50)
}
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Code Samples | Crowded Nightclub? | Random Ramblings

Last edited by chrishirst; 03-09-2010 at 03:37 PM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-09-2010, 03:19 PM Re: How to give a <p> a background like this?
Novice Talker

Posts: 6
Name: Gene
Trades: 0
Thanks for the tip.

Gene
Grady is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to give a <p> a background like this?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10855 seconds with 13 queries