473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using :before and :after pseudo-classes

KeredDrahcir
426 256MB
I have a division that has a background image but it needs to be a varible size. I'm using three images. One of the top, one for the bottom and a repeating one for the middle.

I've only got one div to work with and given the middle background image to that and then used the before and after pesudo classes to place the other images. The image from the main division shows up behind these two since they are semi transparent. Is there a way round this in css or a better method to do it?
Nov 9 '12 #1
8 2358
Rabbit
12,516 Expert Mod 8TB
It would help to see the code.
Nov 9 '12 #2
KeredDrahcir
426 256MB
The code won't help much but here it is.
Expand|Select|Wrap|Line Numbers
  1. <div class="faq">
  2.   <strong>Q.&nbsp;Who was the greatest business man?</strong><br />
  3.   <p><strong>A.&nbsp;</strong>Noah. He kept his stock afloat, while the rest of the world went into liquidation.</p><br />
  4.   <strong>Q.&nbsp;How should my employees let off steam?</strong><br />
  5.   <p><strong>A.&nbsp;</strong>Take them see to see the comedian Sampson. He'll bring the house down.</p><br />
  6. </div>
  7.  
Expand|Select|Wrap|Line Numbers
  1. .faq{
  2.   background: transparent url(../images/image_middle.png) repeat-y center;
  3.   color: #ffffff;
  4.   display: block;
  5. }
  6. .faq:before {
  7.   background: transparent url(../images/image_top.png) no-repeat center top !important;
  8. }
  9. .faq:after {
  10.   background: transparent url(../images/image_bottom.png) no-repeat center bottom !important;
  11. }
Expand|Select|Wrap|Line Numbers
  1. .faq:before {
  2.     padding-top: 20px;
  3.     display: block;
  4.     content: "\A";
  5. }
  6. .faq:after {
  7.     padding-top: 14px;
  8.     display: block;
  9.     content: "\A";
  10. }
  11. .faq{
  12.     margin: 20px 0 5px !important;
  13.     padding: 0 20px 0 15px !important;
  14. }
Nov 12 '12 #3
Rabbit
12,516 Expert Mod 8TB
The code always helps. It sounds like you don't want to see the div's background over the before and after images. So why did you make it transparent?
Nov 13 '12 #4
KeredDrahcir
426 256MB
It's becuase I need to see the page background behind the divs.
Nov 13 '12 #5
Rabbit
12,516 Expert Mod 8TB
That's exactly why you shouldn't make it transparent. Am I misunderstanding what you want?

I also noticed that you didn't specify the content property to specify what content to insert. That's a required property.
Nov 13 '12 #6
KeredDrahcir
426 256MB
What I need is to have a box that's made up of three sections. The top, middle and bottom. Since there box is going to be differnet height at different times I'm doing in three parts instead of one so I can make the middle scroll vertically to take up the required space.
The page has a background image which need to be seen behind the box and so the boxes are semi transparent.

I'm sorry I should have included a bit more of the code. I did include the content property. To allow me to change colour themes quickly I keep colours and backgrounds seperate from layout. I'll edit the previous post to include the code from the other sheet.
Nov 14 '12 #7
Rabbit
12,516 Expert Mod 8TB
Can you post a screenshot? I'm having difficulty understanding what the issue is.
Nov 14 '12 #8
KeredDrahcir
426 256MB
I've taken a different approach. It's worked for me. It doesn't solve the problem I posted though but it's a work round.

I took out the pseudo classes and gave the strong a tallish top image for the background and did a tallish bottom image in the p. They shouldn't ever be too high so they now work as separate elements.

I have encounted another similar problem but I'm still trying to fix that myself.
Nov 15 '12 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Lachlan Hunt | last post by:
Hi, I was wondering if ::before and ::after pseudo-elements can apply to elements styled with the display: table-* properties. None of my tests worked in either Firefox or Opera, yet I could not...
0
by: Lauren Quantrell | last post by:
I'm using SQL Server backend on an Access 2K front end. I populate a subform: Forms!myForm.myChild.Form.RecordSource = "myStoredProcedureName" On that form is a control where the controlsource is...
2
by: Empire City | last post by:
Can someone tell me what is the difference in placing the using in the namespace{} and before the namespace{} ? namespace MyProj { using System; using System.Web; } using System;
4
by: Rocketman | last post by:
How can i program this function in C#
0
by: Aleksey Dmitriyev | last post by:
I am using Session property for my own serializable objects. The code snippet is below: // C# ASP.NET code behind private void btnRun_Click(object sender, System.EventArgs e) { MyClass myObj...
5
by: Mike Nolan | last post by:
I have a before insert trigger that updates a value in another table. It appears that I cannot depend upon that update having taken place in an after insert trigger on the first table. (The one...
3
by: Peter Eisentraut | last post by:
I'm looking at a database-using program (PostgreSQL/libpq and MySQL) which does the following: A daemon process opens a database connection, forks children on request, and those children access...
1
nirmalsingh
by: nirmalsingh | last post by:
i am using ajax+c#+Mysql. with a table,textbox and save button. everything was inserted in database and loaded in table but the problem at rare timings i have to refresh html page to view saved...
10
jamjar
by: jamjar | last post by:
How do I change the form view using VB after the form is opened? I am using the Switchboard pretty much as the wizard loads it. I've tweaked the appearance and a couple of lines of code but I...
4
TheSmileyCoder
by: TheSmileyCoder | last post by:
Im trying to have some fun with the imagecombo control, but so far its alot more frustration then it is fun. From what I have understood I can't tie the imagecombobox directly to a field in a...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.