This is the magic code we are using on this blog because we are sharing tutorials where readers need to copy some codes we share like CSS/JavaScript/HTML etc. So on the same time we do not let readers copy our posts' text are other than codes/Text we want to share. This is possible with this simple CSS code where we enable the copy and paste of text/code we post in "blockquotes" only.
1- Go to Blogger Dashboard
2- Template >> Edit HTML (I recommend you to Back up your template first to avoid error).
3- In the HTML code box, press Ctrl+F then type the code below
]]></b:skin>
4- Now copy and paste the code below just before/above ]]></b:skin>
/*----- Disable Text Selection with CSS Code--- TB----*/
.post blockquote{-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
body {
-webkit-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
Note: In the above CSS code we have enabled the copy/selection of text/code we post using blockquotes by enabling .post blockquote but it may not work for you if your template is using different CSS class for blockquote for e.g. our template using .post blockquote where your template may be using .post-body blockquote or .blockquote. So in that case you need to replace .post blockquote with .post-body blockquote or .blockquote in above CSS code.
That's it! Don't forget to share to your friends!
إرسال تعليق