$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>css - How to add styles in existing function?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

css - How to add styles in existing function?

matteradmin10PV0评论

The goal is to add some internal styles to a function. The function has some if statements, and then it does:

$content .= "
<div>
   <h3>stuff</h3>
   <div>$additional_stuff</div>
</div>";

endwhile;

I'd like to put some styles

in there, too, so it loads when the h3 and additional_stuff loads, but my attempts ways just break it.

The goal is to add some internal styles to a function. The function has some if statements, and then it does:

$content .= "
<div>
   <h3>stuff</h3>
   <div>$additional_stuff</div>
</div>";

endwhile;

I'd like to put some styles

in there, too, so it loads when the h3 and additional_stuff loads, but my attempts ways just break it.

Share Improve this question edited Oct 21, 2018 at 14:27 Tiago Peres 951 gold badge1 silver badge11 bronze badges asked Oct 20, 2018 at 17:25 Justin MunceJustin Munce 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Here's couple of examples on how to add styling to your code.

// Method 1. define classes in another variable, then do styling in styles.css
$classes = 'another-class';

$content .= "
<div id=\"my-id\"class=\"my-class\"> // Method 2. use backslashes to escape double quotes and add id and classes as needed, then do styling in styles.css
   <h3 class=\"{$classes}\">stuff</h3> // Method 1. interpolate classes where needed
   <div style=\"background-color: blue; color: #fff;\">{$additional_stuff}</div> // Method 3. use backslashes to escape double quotes and add inline styles
</div>";

p.s. do remove the comments from the example code before copy-pasting $content to production.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far