- This topic is empty.
March 12, 2012 at 12:51 pm #37112
I want to set the border at the top of the paragraph but instead it sets the border for every line of the paragraph.
p.s. I only want to style achieve this effect in paragraph not by the other style
Thanx in advance :DMarch 12, 2012 at 1:13 pm #98857March 12, 2012 at 2:30 pm #98866
It’s possible that you have set your paragraphs to
display:inline;. If you want what @Paulie_D is showing, you’ll have to make sure that the paragraph is set to
display: block, which is its default type.March 12, 2012 at 11:12 pm #98910
@Paulie_D: Thanx for the reply paulie. I actually want it to be more flexible. Here I have tried by your code http://jsfiddle.net/prathoven/hQRc9/ .Instead I want margin only at the top of the first line(i,e margin to be actual width of the first line not the whole paragraph) not over the box. :D….
@Senff: Thanx for the nice comment :)March 13, 2012 at 5:59 am #98922
That’s a different thing you want than what you initially said then.
If you want to have the line at the top of the paragraph, use @Paulie_D ‘s example.
If you want to have the line at the top of the first line of the paragraph only, you’ll have to wrap it in a div or span and apply the line to that.March 13, 2012 at 7:56 am #98926
I’m thinking there might be something you could do with
but I can’t get it to work.March 13, 2012 at 8:27 am #98929
Indeed you can’t use a border on the first-line pseudo-element. You CAN, however, apply a background image to it, so if you have an image of a line, maybe you want to use that (and set it to repeat-x, obviously). Something like this: http://jsfiddle.net/senff/Wd8ck/
(for some reason it doesn’t always show right away — sometimes I have to switch to another tab and then switch back….hmm!)March 13, 2012 at 9:47 am #98932
@paulie_D & Senff: I guess it can’t be achieved by fair codes….Thanx for your effort..really appreciate it!March 13, 2012 at 11:01 am #98942
I’d want it to just ‘Work’ on a paragraph…I don’t want to have to add paragraphs, spans or whatever.
I thought about a background gradient but I couldn’t get that to work either.
As far as I can see the BG image option would be the only solution..which I did get to work but seemed a lot of hassle for a minor design element.March 13, 2012 at 11:14 am #98943BrightonmikeMember
Paulie, you must always have “content:”” for psuedo elements.March 13, 2012 at 11:27 am #98945
@Brightonmike Actually, not in this case…
I think you need it for ‘before’ and ‘after’ but not in this instance.March 13, 2012 at 6:01 pm #98976joshuanhibbertMember
@Brightonmike You are spot on, pseudo-elements must have the content property declared. However,
:first-lineis a pseudo-class, and they do not use the content property. /cc @Paulie_DMarch 13, 2012 at 6:22 pm #98980
Not sure if that’s true @joshuanhibbert! Since we’re targeting the first line IN a P-element, I believe that makes it a pseudo element.
A pseudo class would target the P-element itself (like
I may be wrong here, but that’s how I always understood it.March 13, 2012 at 6:45 pm #98985joshuanhibbertMember
@Senff Yeah, you are right. I am now stumped as to what I was thinking when I wrote the above comment. These things happen, thanks for the clarification!March 13, 2012 at 6:56 pm #98988
Ha! Man, you confused me there and made me seriously doubt myself! ;)
(still confused about that thing about the need for “content:” though….)
- The forum ‘CSS’ is closed to new topics and replies.