Site logo

Archived topic

A simple rectangular box that stands out

6 replies · Started by steven on May 29, 2022

Viewing posts 1–7 of 7

Hey,

I wonder if you could help. I just want to create a simple rectangular box that will go around text to highlight it on my webpages.

I definitely don't want to use a plugin so I wondered if you guys have any code I can use to do this.

I've installed Code Snippets, ready to add some code (I know you recommend it).

For an example of what I am talking about, see this:

Box

I am not using Generateblocks. If possible I would rather not install plugins.

I intend to insert this box as an ad, using Ad inserter as opposed to adding it on a post by post basis.

So, I need the code to do that. Can you help?

By the way I installed Generate Blocks and I don't see any options at all. No option to create blocks etc.

I absolutely do not want to install the Gutenberg editor - I am using the classic editor.

Hi Steven,

GenerateBlocks works with the Default WordPress Gutenberg Block Editor. It wouldn’t work with the Classic editor.

You would need custom code to achieve as such with the classic editor. We generally suggest using the Block Editor as this is where WordPress is headed now, and most functionalities work with it.

You can add the HTML through a Hook Element and make it appear in your Posts dynamically.

Then, you can add CSS through Appearance > Customize > Additional CSS.

You can try searching for codes in sites like these to achieve as such: https://codepen.io/search/pens?q=advertisement+box&cursor=ZD0xJm89MCZwPTI=

This site may also help: https://www.thesitewizard.com/css/rectangular-box-border.shtml

An sample of HTML code is:

<div class="my-box">
	<h2 class="test-title">
		Test title
	</h2>
	<p class="test-par">
		My description
	</p>
</div>

CSS:

.my-box {
    border: solid 4px black;
    padding: 50px;
    background-color: #fff
}

h2.test-title {
    color: rgb(0,0,0);
    font-weight:bold;
    font-size: 50px;
}

p.test-par {
    color: #ff0000;
}

Hope this helps!

Thanks Fernando - I will give it a go!

I guess I will have to submit to Gutenberg and blocks eventually, but it always messes up my clean pages when I try it.

You can close this now.

You’re welcome Steven!

This archived topic is closed to new replies.