How to solve Struts Submit CSS?

Asked

Viewed 37 times

0

Watch the image;

inserir a descrição da imagem aqui

I’ve done everything to put this button in the right place that I can’t, it just gets weirdly in the corner of the screen, it’s very strange behavior for the one button.

These were my attempts

.button_struts{
position: relative;
right: -780px;
top: -69px;
}

inserir a descrição da imagem aqui

These CSS settings worked to fix the problem, but it’s not a good practice because it doesn’t get responsive, I put this button on the force, it’s not right;

Could someone give me a suggestion?

This is my HTML;

<div class="modal fade" id="modalAddObservacao" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel">
    <s:form cssClass="form-horizontal" role="form" id="formObservacao" action="NaoConformidade!addObservacao" method="post">
        <s:hidden id="codigoNaoConformidade" name="observacao.id" value="%{observacao.id}" />
        <s:hidden name="idRegistroSelecionado" id="idRegistroSelecionado" value=""/>
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" onclick="fecharModalObservacao();" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>

                    <h4 class="modal-title" id="myModalLabel">Observação</h4>

                <div class="modal-body">

                    <input
                        id="idObservacao"
                        type="text" 
                        class="form-control"
                        name="observacao" 
                        value="" />

                    <div id="msgObservacao" ></div>
                </div>
                <div class="modal-footer" align="right">
                    <s:submit onclick="adicionarObservacao(event);" cssClass="btn btn-primary button_struts" key="Salvar"/>
                </div>
            </div>
        </div>
        </div>
    </s:form>
</div>

Additional information

inserir a descrição da imagem aqui

I tried that way too;

<div class="modal fade" id="modalAddObservacao" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel">
    <s:form cssClass="form-horizontal" role="form" id="formObservacao" action="NaoConformidade!addObservacao" method="post">
        <s:hidden id="codigoNaoConformidade" name="observacao.id" value="%{observacao.id}" />
        <s:hidden name="idRegistroSelecionado" id="idRegistroSelecionado" value=""/>
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"  aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                        <h4 class="modal-title" id="myModalLabel">Observação</h4>
                    </div>
                    <div class="modal-body">

                        <input
                            id="idObservacao"
                            type="text" 
                            class="form-control"
                            name="observacao" 
                            value="" />


                        <div id="msgObservacao" ></div>
                    </div>
                    <div class="modal-footer" align="right">
                        <s:submit onclick="adicionarObservacao(event);" cssClass="btn btn-primary" key="Salvar"/>
                    </div>

           </div>
        </div>
    </s:form>
</div>
  • You want to put in the right corner of the modal footer?

  • Yeah, that’s right! :)

  • But the modal footer buttons are already on the right by default. No need to change the CSS.

  • He’s not getting right, he’s getting as it is in the picture.

  • It is getting like in the image because you are applying properties that move the button. This modal is Bootstrap, right? Try without these properties, that is, delete this CSS .button_struts{&#xA;position: relative;&#xA;right: -780px;&#xA;top: -69px;&#xA;}

  • I am hard to explain, the fact that you have not understood is not your fault, the problem is the following, without these CSS settings that I put the screen is as it is in the first image of this post, but if I put these CSS settings will be fixed but it is not a good practice because I put the button in place by force, I need to put the button in place in the correct way.

  • What version of Bootstrap are you using?

  • Bootstrap v3.3.6

Show 3 more comments

1 answer

1

Bootstrap 3 modal footer already aligns the elements on the right by default, due to native property text-align: right:

inserir a descrição da imagem aqui

That is, you do not need to apply styles to position the button, it is already in the correct position normally, as shown in the example below:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>


<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalAddObservacao">
  Abrir modal
</button>
<div class="modal fade" id="modalAddObservacao" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel">
    <form class="form-horizontal" role="form" id="formObservacao" action="NaoConformidade!addObservacao" method="post">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" onclick="fecharModalObservacao();" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>

                    <h4 class="modal-title" id="myModalLabel">Observação</h4>
               </div>
                <div class="modal-body">

                    <input
                        id="idObservacao"
                        type="text" 
                        class="form-control"
                        name="observacao" 
                        value="" />

                    <div id="msgObservacao" ></div>
                </div>
                <div class="modal-footer">
                    <button onclick="adicionarObservacao(event);" class="btn btn-primary button_struts" key="Salvar">Salvar</button>
                </div>
            </div>
        </div>
        </div>
    </form>
</div>

You don’t need that attribute either align="right" in the div footer of modal. And missed closing the modal header div, otherwise she will "swallow" the footer div.

  • I understand that you are striving to help me, the button really stay in the right place, but I can not submit the information entered on screen in the database, the screen can only save in the database the information entered on the screen if you use the component s:Submit from Struts, that’s why I’m trying to make this component work and not use a bootstrap component.

  • Do you realize that the div has to be closed <div class="modal-header">?

  • Go to inspect browser elements and see how this code is rendered: <s:submit onclick="adicionarObservacao(event);" cssClass="btn btn-primary button_struts" key="Salvar"/>.

  • It is closing normal, I have created a gif file and put in the post, take a look at me please you will see that it is properly closing the Divs

  • Not closing. Your gif shows that the footer div is inside the header div.

  • I went down several levels of div down to see if it stayed in place, but it didn’t help, the way it could help me would be put the way you think it should stay.

  • You have to close the header div. Put a </div> before <div class="modal-body">.

  • I just made that attempt, and it didn’t work, I put that attempt in the post.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.