Jump to content



Change CSS for included files

  • You cannot reply to this topic
4 replies to this topic

#1 sebr1ng   Members   -  Reputation: 100

Like
0Likes
Like

Posted 19 February 2012 - 08:06 AM

Hello!

I'm not a skilled web-programmer (as it's obvious from the question Posted Image).
My problem is the following:
I have a "New Page" into which I included two files (with PHP include function). One of them is html and one of them is txt.
The page into which I included the two files has different design than the html document included, so I want to change the CSS of the included part on my new page. The result would be that included html file on its own has it's own CSS design and on the "new page" into which the html is included it has different design. Huh, I hope I didn't complicate to much Posted Image

Another question related to the included txt file:
The data in my txt file is organized so one word is in each row. When included (because it's raw data) the parsed result is that all words are in one row. How can I put the output in my "new page" (with txt included) so it's one word in each row?

Thanks a bunch!

Ad:

#2 Antheus   Members   -  Reputation: 2303

Like
1Likes
Like

Posted 19 February 2012 - 08:17 AM

Quote

The page into which I included the two files has different design than the html document included, so I want to change the CSS of the included part on my new page. The result would be that included html file on its own has it's own CSS design and on the "new page" into which the html is included it has different design.

There is no completely reliable way, since styles may clash. A simple way is to include the section inside a div:
<div class='inserted'> ... </div>
Then prefix rules in that CSS with 'inserted'. It might be necessary to manually tweak a thing or two.

Quote

The data in my txt file is organized so one word is in each row. When included (because it's raw data) the parsed result is that all words are in one row. How can I put the output in my "new page" (with txt included) so it's one word in each row?

Some formatting needs to be applied to the txt file. Ideally, it would be formatted as <ul> to preserve semantic meaning.

Depending on where the txt comes from, it might be simpler to modify that or modify whatever generates it.

#3 sebr1ng   Members   -  Reputation: 100

Like
0Likes
Like

Posted 19 February 2012 - 12:26 PM

View PostAntheus, on 19 February 2012 - 08:17 AM, said:

Quote

The data in my txt file is organized so one word is in each row. When included (because it's raw data) the parsed result is that all words are in one row. How can I put the output in my "new page" (with txt included) so it's one word in each row?

Some formatting needs to be applied to the txt file. Ideally, it would be formatted as <ul> to preserve semantic meaning.

Depending on where the txt comes from, it might be simpler to modify that or modify whatever generates it.

What if it's hard to modify the source that generates the txt file? Is there a way to format the output with CSS?

Thanks!

#4 Antheus   Members   -  Reputation: 2303

Like
0Likes
Like

Posted 19 February 2012 - 01:35 PM

$string = get_include_contents('file.txt');

$tok = strtok($string, " ");
echo "<ul>";
while ($tok !== false) {
	echo "<li>$tok</li>";
	$tok = strtok(" ");
}
echo "</ul>";
Or something similar.

#5 jbadams   Staff   -  Reputation: 2082

Like
0Likes
Like

Posted 20 February 2012 - 05:30 PM

View PostAntheus, on 19 February 2012 - 08:17 AM, said:

There is no completely reliable way, since styles may clash. A simple way is to include the section inside a div:
...

Then prefix rules in that CSS with 'inserted'. It might be necessary to manually tweak a thing or two.
To avoid any clashes with the existing styles, you could first apply a "reset css" to the 'inserted' section and then proceed as per your suggestion to apply new styles only to the inserted content using an 'inserted' prefix.


If it's possible to do so it would be better to design avoid to the problem all together by not having existing styles in the inserted content.
- Jason Adams.

Why you shouldn't use Dev-C++ | Asking Better Questions
Royalty Free Music & SFX from AudioJungle | Free Sprites from SpriteLib
Store and sync your files online and across computers with Dropbox -- 2GB of online storage for free.







We are working on generating results for this topic
PARTNERS