отзывчивый bootstrap 4 cols для всех устройств - PullRequest
1 голос
/ 30 апреля 2020

Я работаю над адаптивной страницей профиля для всех устройств, поэтому я использовал сеточную систему bootstrap 4, чтобы разделить страницу для своих нужд. Я хотел, чтобы страница выглядела следующим образом: - this в настольных компьютерах и вот так: - this

так что я попробовал col-sm работать ответственно с небольшими экранами фрагмент кода

/* Profile Main Page Cards , holders...etc */
.holderTitle{
	font-family: hana;
	font-size: 34px !important;
	color:black !important;
	text-align: center !important;
}
/* Profile Image Thubmail */
.ProfileAvatar{
	border: 1px solid #ddd; /* Gray border */
	border-radius: 4px;  /* Rounded border */
	padding: 5px; /* Some padding */
	width: 150px; /* Set a small width */
  }
  /* Add a hover effect (blue shadow) */
.ProfileAvatar:hover {
	box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
  }
.holderText{
	color:black !important;
}
.messagebtn{
	text-align: center !important;
	font-family: hana !important;
}
.fontawsomeBIO{
	font-family: hana !important;
}




/* 
  ##Device = Desktops
  ##Screen = 1281px to higher resolution desktops  ( large Mointer )
*/

@media (min-width: 1281px) {
	/* Profiler Card and Container (Profile Holder) on large Screen */
	.profileholder{ 
		width:45%;
		height: auto;
	}
	/* ProfileHolder Ends Here */
	/* Profile Content Card And Container  */
	.ProfileContent{
		width: 100%;
		height: auto;
	}
  }
  
  /* 
	##Device = Laptops, Desktops
	##Screen = B/w 1025px to 1280px
  */
  
  @media (min-width: 1025px) and (max-width: 1280px) {
	
	.profileholder{
		width:70%;
		height: auto;
	}
	/* ProfileHolder Ends Here */
	/* Profile Content Card And Container  */
	.ProfileContent{
		width: 100%;
		height: auto;
	}	
  }
  
  /* 
	##Device = Tablets, Ipads (portrait)
	##Screen = B/w 768px to 1024px
  */
  
  @media (min-width: 768px) and (max-width: 1024px) {
	
	.profileholder{
		width:95%;
		height: auto;
	}
	/* ProfileHolder Ends Here */
	/* Profile Content Card And Container  */
	.ProfileContent{
		width: 100%;
		height: auto;
	}	
  }
  
  /* 
	##Device = Tablets, Ipads (landscape)
	##Screen = B/w 768px to 1024px
  */
  
  @media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
	.profileholder{
		width:75%;
		height: auto;
	}
	/* ProfileHolder Ends Here */
	/* Profile Content Card And Container  */
	.ProfileContent{
		width: 100%;
		height: auto;
	}	
  }
  
  /* 
	##Device = Low Resolution Tablets, Mobiles (Landscape)
	##Screen = B/w 481px to 767px
  */
  
  @media (min-width: 481px) and (max-width: 767px) {
	.profileholder{
		width:85%;
		height: auto;
	}
	/* ProfileHolder Ends Here */
	/* Profile Content Card And Container  */
	.ProfileContent{
		width: 90%;
		height: auto;
	}
  }
  
  /* 
	##Device = Most of the Smartphones Mobiles (Portrait)
	##Screen = B/w 320px to 479px
  */
  
  @media (min-width: 320px) and (max-width: 480px) {
	.profileholder{
		width:100%;
		height: auto;
	}
	/* ProfileHolder Ends Here */
	/* Profile Content Card And Container  */
	.ProfileContent{
		width: 100%;
		height: auto;
	}	
  }
<html>
<head>
<title>Responsive Profile</title>
<link rel="stylesheet" type="text/css" href="..\Styles\profile.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"><!-- Bootstrap CDN Font-awesome -->
</head>
<body>
<!-- Bootstrap Jquery JavaScripts  -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script><!-- Bootstrap Jquery JavaScripts  -->
<div class="row">
		<div class="col-sm-6">
			<div class="container">
				<br>
				<div class="card profileholder">
					<img class="card-img-top ProfileAvatar" src="..\upload\tmp\img.jpg" alt="alt"></img>
					<div class="card-body">
						<h4 class="card-title holderTitle">الإسم</h4><br><br>
						<a name="PMbutton" id="private" class="btn btn-danger btn-block messagebtn" href="#" role="button">رسالة</a>
						<a name="d" id="ds" class="btn btn-dark btn-block messagebtn" href="#" role="button">متابعة</a>
						<i class="fas fa-map-marker-alt fas-3x" aria-hidden="true"></i>
					</div>
				</div>
			</div>
		</div>
		<div class="col-sm-auto">
		<br>
			<div class="card ProfileContent">
				<div class="card-body">
				Content Here tab panel....etc
				</div>
			</div>
		</div>
	</div>
</body>
советую: - показать код на полной странице

по крайней мере, самое важное - это правильный контейнер под col-sm-auto < --- тег содержит панель вкладок, на панели будет более 4 вкладок, что достаточно для всей ширины экрана смартфона, поэтому на панели будет отображаться любое предложение, чтобы сделать его отзывчивым.

1 Ответ

1 голос
/ 30 апреля 2020

Bootstrap дает вам несколько встроенных медиа-запросов, с помощью которых вы можете определить свой макет.

  • Очень маленькие устройства (портретные телефоны, менее 576 пикселей) Нет медиазапроса, так как это значение по умолчанию в Bootstrap
  • Небольшие устройства (ландшафтные телефоны, 576 пикселей и выше) @media (min-width: 576px) {...}
  • Средние устройства (планшеты, 768px и выше) @media (min-width: 768px) {...}
  • Большие устройства ( настольные ПК, 992 пикселей и более) @media (минимальная ширина: 992 пикселей) {...}
  • Очень большие устройства (большие настольные компьютеры, 1200 пикселей и более) @media (минимальная ширина: 1200 пикселей) {... }

Вы можете использовать мобильный первый подход для разработки макета. Начиная с 0px до 575px, будет указано вначале, что когда вы поднимаетесь выше в разрешении, вы можете использовать медиа-запросы для обработки вашего макета. Класс col-sm-6 дает вам возможность использовать 6 столбцов подряд. Если вы хотите, чтобы этот col уменьшился до 4, вы можете добавить col-lg-4 помимо col-sm-6. Таким образом, ваш дизайн станет отзывчивым.

enter image description here

Что касается панели вкладок, это зависит от вашего дизайна. Вы также можете применить вложенную технику или подход со списком носителей для обработки вашего дизайна с другим разрешением. Пожалуйста, рассмотрите bootstrap документацию для полного руководства. Вы также можете изменить col-sm-auto на col-sm-6.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...