Responsive screen size for experiment 适应实验的屏幕尺寸

huangapple go评论60阅读模式
英文:

Responsive screen size for experiment

问题

我希望我在这里提供足够的细节。

我目前正在尝试在Labjs上设计一个实验,并想知道是否有办法使用HTML或CSS使网站对屏幕大小更具响应性?我的意思是,我是否可以使用CSS/HTML根据用户屏幕的大小调整刺激的大小?

我的当前CSS代码是这样的:

/* 请在这里定义您的自定义样式 */

cons_left {
  margin-left: 10%;
  margin-right: 10%;
} 

.pickparent {
  position: relative;
  top: 0;
  left: 0;
 // border: 3px solid black;
} 

.pickpicker {
  position: relative;
  top: 0;
  left: 0;
//  border: 3px solid red;
} 

.pickimage {
  filter: grayscale(100%);
  position: absolute;
  margin: auto;
  z-index: 2;
 // border: 3px solid red;
} 

#location_percentage, #color_percentage {
  font-size: 70px;
  text-align: center;
  display: block;
  margin: 0 auto;
}

.feedback, .percentage {
  font-size: 70px;
  text-align: center;
}

.feedback {
  font-size: 70px;
  margin-top: 450px;
  display: block;
  line-height: 70px;
}

.feedback:first-line {
  font-size: 70px;
  margin-top: 100px;
  display: block;
  line-height: 120px;
}

.percentage {
  margin-top: 20px;
  margin-bottom: 20px;
}

#next-button {
    display: none;
    align-items: center;
  }

.message {
  font-size: 50px;
  text-align: center;
  position: absolute
  margin: 20%
}
英文:

I hope I am providing enough detail here.

I am currently trying to design an experiment on Labjs and wanted to know if there is a way to make the website more responsive to screen size using HTML or CSS? What I mean by this is that can I use CSS/HTML to adjust the size of the stimuli depending on the size of the screen of the user?

My current CSS code is this:

/* Please define your custom styles here */


cons_left {
  margin-left: 10%;
  margin-right: 10%;
} 

.pickparent {
  position: relative;
  top: 0;
  left: 0;
 // border: 3px solid black;
} 

.pickpicker {
  position: relative;
  top: 0;
  left: 0;
//  border: 3px solid red;
} 

.pickimage {
  filter: grayscale(100%);
  position: absolute;
  margin: auto;
  z-index: 2;
 // border: 3px solid red;
} 

#location_percentage, #color_percentage {
  font-size: 70px;
  text-align: center;
  display: block;
  margin: 0 auto;
}

.feedback, .percentage {
  font-size: 70px;
  text-align: center;
}

.feedback {
  font-size: 70px;
  margin-top: 450px;
  display: block;
  line-height: 70px;
}

.feedback:first-line {
  font-size: 70px;
  margin-top: 100px;
  display: block;
  line-height: 120px;
}

.percentage {
  margin-top: 20px;
  margin-bottom: 20px;
}

#next-button {
    display: none;
    align-items: center;
  }

.message {
  font-size: 50px;
  text-align: center;
  position: absolute
  margin: 20%
}

I have tried change various attributes of the CSS to make it responsive but I've had no luck so far. I've also tried to implement a scaling task where the user has to adjust the size of a rectangle to the size of a card but I can't find a solution here either.

Thank you for your help!

答案1

得分: 1

你可以使用CSS媒体查询来根据屏幕尺寸设置网站的样式。

例如:

.message {
  font-size: 50px;
  margin: 20%;
  position: absolute;
}

@media screen and (min-width: 600px) {
  .message {
    font-size: 70px;
    margin: 50%;
  }
}

在上面的代码中,message 类的字体大小设置为50px,边距设置为20%。但在大于600px的屏幕上,字体大小设置为70px,边距设置为50%。

如果不指定媒体查询,样式将应用于所有屏幕尺寸。

不需要重复规则,例如,位置适用于所有屏幕尺寸,因此不需要在媒体查询中指定它。

类似问题

Mozilla CSS媒体查询

英文:

You can use CSS media queries to have your website styled according to the screen size.

For example:

.message {
  font-size: 50px;
  margin: 20%;
  position: absolute;
}

@media screen and (min-width: 600){
.message {
  font-size: 70px;
  margin: 50%;
}
}

In the above code the message class the font-size is set to 50px and the margin to 20%. But on screens bigger than 600px, the font-size is set to 70px and the margin to 50%.

If you don't specify a media query, it'll be applied on all screen sizes.

You don't need to duplicate the rules, for example, the position is applied to all screen sizes, so no need to specify it in the media query.

Similar question

Mozilla CSS_media_queries

答案2

得分: 1

你可以使用媒体查询来使你的网站具有响应式的屏幕大小。

@media only screen and (max-width:
600px) {
body {
background-color: lightblue;
}
}

你可以在这里了解更多信息:
W3schools媒体查询

英文:

You can use media queries to make responsive screen size for your site.

@media only screen and (max-width: 
600px) {
  body {
   background-color: lightblue;
  }
}

You can learn more about that here:
W3schools media queries

huangapple
  • 本文由 发表于 2023年6月29日 19:29:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76580614.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定