【问题标题】:What do I need to change to my web page responsive?我需要对我的网页做出什么改变?
【发布时间】:2017-09-22 01:51:59
【问题描述】:

我需要让我的页面具有响应性。无论屏幕大小如何,我的内容都应该垂直和水平对齐,并且我的浏览器边缘和内容之间会有一些边距。

小提琴链接:here

body {
	background-color: black;
}
.parent {
    display: table;
    position: absolute;
    height: 100%;
    width: 100%;
}

.centered-content {
	display: table-cell;
    vertical-align: middle;
    margin:0 auto;
}
p {
	font-family: Lato;
	font-size: 21px;
	font-weight: 300;
	color: white;
	margin: 0 auto;
	max-width: 640px;

}
@media (max-width: 991px) {
  .default {
    width: 520px;
    margin: 0 auto;
  }
  .centered-content {
    width: 640px;
    margin-right: auto;
  }
}

@media (max-width: 767px) {
  .centered-content {
    width: 520px;
  }
}

@media (max-width: 479px) {
  .centered-content {
    width: 272px;
  }
  p .default {
    max-width: 272px;
    margin-top: 48px;
    font-size: 19px;
  }
}
div class="parent">
	<div class="centered-content">
	      <p class="default">
	        Hey, I'm lorem.
	        <br><br>
	        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
	        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
	        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
	        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
	        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
	        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
	        <br><br>
	        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
	        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
	        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
	        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
	        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
	        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
	      </p>
	</div>

【问题讨论】:

  • 请提供小提琴链接。
  • 编辑您的问题,然后正确添加链接。并在问题中添加代码
  • 感谢 PurpleSoft 的编辑。对不起,我是stackoverflow的新手

标签: html css twitter-bootstrap


【解决方案1】:

您的问题确实不清楚。我的 2 美分是您应该使用引导程序或任何其他响应式框架来帮助您寻求响应性。 http://getbootstrap.com

阅读文档并了解网格系统

编程愉快!

【讨论】:

  • 我也添加了引导程序。但什么也没有发生。你可以看到我的代码sn-p。感谢 PurpleSoft。
【解决方案2】:

用户@media 查询在您的CSS 这里是媒体查询大小

/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen and (max-width : 320px) {
/* Styles */
}

/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}

/* iPads (landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}

/* iPads (portrait) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}
/**********
iPad 3
**********/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen  and (min-width : 1224px) {
/* Styles */
}

/* Large screens ----------- */
@media only screen  and (min-width : 1824px) {
/* Styles */
}

/* iPhone 4 ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}

@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}

/* iPhone 5 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

/* iPhone 6 ----------- */
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

/* iPhone 6+ ----------- */
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

/* Samsung Galaxy S3 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}

/* Samsung Galaxy S4 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}

@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}

/* Samsung Galaxy S5 ----------- */
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}

@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}

【讨论】:

  • 因为这确实是一种可能性,似乎 OP 在使他/她的网页响应时也遇到了问题。我们为什么不让他/她尝试引导以提高响应能力
  • 我正在使用媒体查询但找不到方法
  • 你最好使用Bootstrap这里的链接:getbootstrap.com/getting-started/#download
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-22
  • 1970-01-01
  • 2019-04-26
  • 1970-01-01
  • 2023-03-11
  • 2013-07-05
  • 1970-01-01
相关资源
最近更新 更多