Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS How to automatically add space in CSS after buttons?

Kaworu

Active Coder
Hi.

I am making a very simple website. It consists mostly of buttons which are links to other pages on the net. The buttons are top-down oriented. I want to code is CSS in a way that will automatically add space after each button. Sadly, I have completely no idea how to do it other than putting <br> after every button, which I wanna avoid.

Source code:

HTML:
<!DOCTYPE html>

<html>

    <head>
        
        <link rel="stylesheet" href="style.css">
        
    </head>

    <body>
            
        <a href="http://www.wp.pl"><button type="button" class="mybutton">Wp.pl</button></a>
        <a href="http://www.onet.pl"><button type="button" class="mybutton">Onet.pl</button></a>

    </body>

</html>

CSS:
.mybutton
{
    width: 66%;
    height: 50px;

    border: 2px solid black;
    
    position: relative;
}

.mybutton::after
{
    /* HERE SHOULD BE SOME CODE, BUT I DON"T KNOW WHICH :( */
}
 
Depending on how many buttons you end up using, you may try using a table to set them up so you can set the row and column height/width as well as keeping a nice border between them.

Like this:
[CODE lang="html" title="HTML Example"]<table>
<tr>
<th>Links</th>
</tr>
<tr>
<td>
<button>
<a href="websiteblahblah.com" target="_blank">Link Name</a>
</button>
</td>
</tr>
<tr>
<td>
<button>
<a href="websiteblahblah.com" target="_blank">Link Name</a>
</button>
</td>
</tr>
</table>[/CODE]

[CODE lang="css" title="CSS Example"]table{
margin: auto;
width: 50%;
padding:10px;
}
table, th, td {
border: 1px solid black;
text-align: center;
}[/CODE]

As far as your after CSS, all you really need to do is change the text color so that the user knows it's a visited link. Hope this helps!
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom