How to add code area css style to HTML - css

I am trying to create a blog in wordpress. Since I might need to add some code blocks to my posts, I was wondering if there is any CSS style to represent code block.
A very simple example would be stackoverflow code tag (shown below)
<script type="text/javascript">
alert('this is example of what i need to do ') ;
</script>

Since you are using wordpress, there are plugins to do that. Just by looking at http://wordpress.org/extend/plugins/tags/syntax-highlighting there seems to be quite a few to choose from.

Related

unable to edit css style for tweet button

I am working on styling a Tweet button by modifying the CSS class using font-awesome without success. here is the HTML code taken from Twitter:
Tweet<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>.
The issue originates from the widgets.js, whenever it loads, whatever I do it will change the style to the classic one, and in case removing or bypassing "twitter-share-button" class, the button won't work anymore.
any suggestion on how to use a specific style on tweet button?
Tweet.
to be honest, I did find a solution, although not the way I liked...
I did some modifications to the code to become as follows:
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
txt = "websitename"; $ttr = urlencode("$titleforarticle") . "\n"; $lk = urlencode("$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]") . "\n";
you may use JS instead of PHP.
better solutions are always welcome!

2sxc: Adding more content templates in the same page does replicate link tags for css and js

I'm new to dnn and 2sxc.
Just wondering if I'm adding for example a card template (image,some text, a link), adding in the html template link tag to css/js, when adding that content more times in the page obviously the link tags are replicate in page source and it isn't so nice.
For example:
<script src="[App:Path]/script.js" type="text/javascript" data-enableoptimizations="100"></script>
it is going to be replicate in page.
Maybe I'm missing something, there is a better way to do it?
Thanks you :)
If you tried it, you should see that it will only be included once, IF you have the data-enableoptimizations included :)
So allready taken care of
Maybe i found the issue...
When I edit a template, selecting Html snippets in the combo to the right, then click on css, style-sheet it is writing a demo link tag, but it is not adding the type (type="text/css"), without it seems not work..
Maybe it could be fixed in a next release :)

Add html to drupal 6 page

I am trying to add html to the bottom of all the pages of a drupal 6 site.
I tried following Adding HTML to Drupal closure? but I'm not familiar enough with drupal to follow it.
The code is a google remarketing code, so I can't use drupal_add_js because the code I have already has script tags and , and the drupal_add_js wraps everything in tags.
hook_footer seems to be the best solution but I can't figure out how to use it.
Thanks
The best solution is to use hook_footer().
You have to create a Drupal module. I think this link might help you: https://drupal.org/developing/modules/7
Basically you have to create a module an implementes hook_footer(). In here you can add your custom html.
But there are another ways to do it. For example you can edit your theme. Find the page.tpl.php file in your theme and add, in the footer, the content. It's appears in all pages.
Another option is to create a block with full html filter, and add your html.
Regards.
I ended up putting the html i needed in $vars["closure"]

How can I add an "onclick" in an input tag?

I am trying to insert
onclick="countCheckboxes()"
within the input tag. Is there any way to do this in CSS? I tried the following, but didn't work:
input[type=checkbox]:after {
content: "onclick="countCheckboxes()"";}
So that it would eventually output this
<input type="checkbox" onclick="countCheckboxes()">
This is for a Wordpress form. Maybe I could add something in the functions.php template to enable me to do this?
You cannot generate Javascript in css. Please refer to this for more information: Using Javascript in CSS
I am guessing that you want to keep your markup clean of JS? If so, the best thing would be to abstract the JS from your markup in a separate js file. There you can navigate the dom and append functions whichever way you require. You can do this with either vanilla Javascript or a JS framework(like Jquery) which simplifes the process a lot.
I'm happy to set up a demo if you wish to learn how.

Syntax highlight plugin without JS, pure CSS

i want to display some source code on ajax loaded page via Facebox plugin.
But if i try to add script tag
<script src="src/prettify.js"></script>
Facebox remove all script tags in loaded page.
So i need pure CSS based solution for syntax highlighting or solve removing of script tags by facebox.
Thx for any help.
Browsers don't execute script tags pulled in via AJAX: Inline jQuery script not working within AJAX call
The CSS only solution would be to manually wrap your code in spans and set all the coloring in CSS, which is definitely not ideal.
The best solution here would be to include <script src="src/prettify.js"></script> on the main page doing the Facebox ajax calls and just making sure that prettify is triggered on the AJAXed content after it's pulled in like so:
$(document).bind('beforeReveal.facebox', function() {
prettyPrint();
});

Resources