E
E
Evgeny Romashkan2018-05-09 13:05:46
css
Evgeny Romashkan, 2018-05-09 13:05:46

How to display the form in the center of the screen?

Actually, there is a form for editing a product/category, etc. Once the page is loaded, it is hidden via v-if:visible(vue.js).
By clicking on the button to edit a product/category, etc. you need to show this form in the center of the screen. How can such a thing be implemented?
Now done like this:

.background {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    align-content: center;
    justify-content: center;
    overflow: auto;
    .center {
    ...
   }

When visible becomes true through vue, the user is thrown to the top of the page (if he has already scrolled down with the wheel). And you need the form to be displayed in the center of the screen anywhere on the page.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BitRouter, 2018-05-09
@EvgeniiR

css

.myclass {
    position:fixed;
    width:400px;
    height:200px;
    margin-left:-200px;
    margin-top:-100px; 
    left:50%;
    top:50%;
}

JS
var widthDevice = $(window).width(),
      heightDevice = $(window).height();
var widthMain = $('.myclass').width(),
      heightMain = $('.myclass').height();
$('.myclass').css({
  'left': widthDevice - (widthMain  / 2)
//...
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question