pass from Jquery to CSS3

Asked

Viewed 54 times

2

Some way to do this in CSS3?

if(window.innerWidth <= 1000) {
  var ecra = window.innerWidth;
  $(".topo").css("height",ecra*0.293);
}

I tried to

@media screen and (min-width: 0px) and (max-width:1000px) {
  .topo {
    height: calc(device-width*0.293);
}

But I can’t find the screen size with css

  • in css not t in how only form is vc using vh or %

  • What do you mean? I don’t understand!

  • face css or vc uses % in the sizes or pixel or VH of a googada but anyway to catch the current screen height so with javascript

  • It is. The problem is that with each screen resolution I have a different size for a div

  • cannot use javascript ?

  • no, I also tried Calc(device-width*0.293) but it did not help. I could not recover the size of the screen

  • cara javascript funciona semrpe usei para calcula tamanho da tela da uma googada q vc acha: procure por how to get screen size Whit java script

  • The way I did is working correctly. But I’d like to leave only css if it’s possible

  • Screen size is 100%. calc(100% * 0.293). The numbers of the operators must be separated. It cannot be attached: calc(100%*0.293).

  • the problem is that I need to multiply 100%* 0.293 and find the height of a div from the screen length. Will it work?

  • Javascript only.

  • rsrs, tried here, gave no. Thanks!]

Show 7 more comments

1 answer

4


has yes how you do it:

using the height property the measurement unit vw (viewport width), to calculate from the height of the monitor, vh (viewport height) is used).

I’m considering that you want the height of <div> classy .topo is equal to 29.3% of the display width.

@media screen and (min-width: 0px) and (max-width:1000px) {
  .topo {
    height: 29.3vw;/*VW é a unidade de medida da largura do monitor*/
    /*height: calc(29.3vw - 50px); opcionalmente e comentado, a forma correta da função calc do css3*/
}

Browser other questions tagged

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