0

I'm trying to get my buttons aligned in my display. If I try to use float: right; nothing happends. Below you can find a screenshot:enter image description here

So I'm trying to get these buttons all in a row below each other. I also tried using a table, but that one screws up my design of my hrefs Here you can find my html:

        <div class="LineField"> 
            <p>Axo 800</p>
            <a href="Planning.php?id=1"  class="LineButton">Planning</a>
            <a href="DataAnalyse.php?id=1"  class="LineButton">Data analyse</a> 
        </div>
        <div class="LineField">
            <p>JC-FSX</p>
            <a href="Planning.php?id=2"  class="LineButton">Planning</a>
            <a href="DataAnalyse.php?id=2"  class="LineButton">Data analyse</a>
        </div>

etc. etc.

css:

        .LineField
        {               
            width: 50%;
            height: 8%;
            margin-bottom: 15px;
            padding-top: 5px;   
            margin-left: auto;
            margin-right: auto;
            background: #191748;
            border: 0.1em #191748;
            border-radius: 1em;
            color: white;

            /* vertical alignment */
            display: flex;
            align-items:center;     
        }

        .LineField p
        {
            margin-left: 25px;
            margin-right: 25px;
            Font-size: 200%;
        }
        .LineButton
        {
            border-radius: 0.5em;
            width: 30%;
            height: 50%;
            background: linear-gradient(#ffffff, #c4c4ff);
            margin-left: 3%;
            margin-right: 3%;
            padding-top: 5px;
            color: #191748;
            font-size: 150%;
            font-weight: 500;   
            text-decoration: none;      
        }
3
  • Setting a specific width to your p elements will resolve your buttons alignment issue. Commented Feb 2, 2016 at 9:41
  • It will be a lot more easier to achieve the desired alignment using the grid system of bootstrap Commented Feb 2, 2016 at 9:44
  • @Maqk, ye lol. Thats actually pretty easy. Havent thought about that one.... Commented Feb 2, 2016 at 9:45

3 Answers 3

1

You can set the width for the p element like below

    .LineField p
    {
        margin-left: 25px;
        margin-right: 25px;
        Font-size: 200%;
        width: 130px;
    }

Updated Code Here

Sign up to request clarification or add additional context in comments.

Comments

1

Just use the CSS below:

.LineField p {
   margin-left: 25px;
   margin-right: 25px;
   Font-size: 200%;

   float: left;
   width: 16%;
}

Comments

0

You can set the width of LineButton class like below

 .LineButton
    {
        border-radius: 0.5em;
        width:50%;
        height: 50%;
        background: linear-gradient(#ffffff, #c4c4ff);
        margin-left: 1%;
        margin-right: 1%;
        padding-top: 5px;
        padding-left: 5%;
        color: #191748;
        font-size: 150%;
        font-weight: 500;   
        text-decoration: none;      
    }

Please see the updated code below

Sample Code

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.