Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



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

Posts: 849
Name: Matt Pealing
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.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

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

Posts: 40
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, 02:13 PM Re: How to give a <p> a background like this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,505
Name: Chris Hirst
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
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-09-2010, 02:52 PM Re: How to give a <p> a background like this?
angele803's Avatar
Perfectly Imperfect

Posts: 1,774
Name: Stephanie
Location: Oklahoma
Trades: 2
I think this article will help you: http://css-tricks.com/text-blocks-over-image/
__________________

Please login or register to view this content. Registration is FREE
angele803 is offline
Reply With Quote
View Public Profile
 
Old 03-09-2010, 03:20 PM Re: How to give a <p> a background like this?
pealo86's Avatar
Super Spam Talker

Posts: 849
Name: Matt Pealing
Location: England, north west
Trades: 0
Great thanks for the help
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 03-09-2010, 03:47 PM Re: How to give a <p> a background like this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,505
Name: Chris Hirst
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
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 03-09-2010 at 04:37 PM..
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-09-2010, 04: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.29400 seconds with 12 queries