【发布时间】:2016-11-14 20:16:28
【问题描述】:
问题:我的图像在除 iphone 之外的所有平台上都能响应。
在 iphone 版本的网站上,它正在炸毁图像,我不确定。
我认为以下方法可以解决除了 IPHONES 和 IPADS 之外的歪斜问题
#homepage .carousel .item {
height: auto !important;
}
#homepage .carousel .item img {
min-width: 100% !important;
max-width: 100% !important;
height: auto !important;
position: relative !important;
}
.carousel-indicators {
bottom: 2%;
}
话虽如此,我还发布了我所做的其余 css 以使其响应不同的尺寸:
/***TEST 1.2***/
#homepage .carousel .item {
height: auto !important;
}
#homepage .carousel .item img {
min-width: 100% !important;
max-width: 100% !important;
height: auto !important;
position: relative !important;
}
.carousel-indicators {
bottom: 2%;
}
@media screen and (max-device-width: 375px) and (max-device-height: 667px) {
#homepage .carousel .item {
height: auto !important;
}
#homepage .carousel .item img {
min-width: 100% !important;
max-width: 100% !important;
height: auto !important;
position: relative !important;
}
.carousel-indicators {
bottom: 2%;
}
}
@media (max-width:331px){
.navbar-header{
margin-left:-20px;
}
.navbar-toggle{
position: relative;
float: right;
padding: 9px 10px;
margin-top: 8px;
margin-right: 0px;
margin-bottom: 8px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
}
@media screen and (max-width:331px) and (-webkit-min-device-pixel-ratio:0) {
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 71px;
}
}
/*
@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation : portrait) {
#homepage .carousel .item {
height: 200px !important;
}
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: 200px !important;
position: relative !important;
}
}*/
@media (min-width:729px) and (max-width:748px){
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 71px;
}
}
@media(max-width: 728px) and (orientation:portrait){
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 71px;
}
}
@media screen and (max-width: 728px) and (orientation:portrait) and (-moz-images-in-menus:0){
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 0px;
}
}
/*Firefox*/
@media screen and (max-width: 748px) and (-moz-images-in-menus:0) {
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 0px;
}
}
@media(max-width: 768px) and (orientation:landscape){
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 71px;
}
}
@media screen and (max-width: 768px) and (orientation:landscape) and (-moz-images-in-menus:0){
#homepage .carousel .item img {
min-width: 100% !important;
width: 100% !important;
height: auto !important;
position: relative !important;
margin-top: 0px;
}
}
@media (max-width: 767px){
.image-margin-top2 {
margin-top: 182px !important;
}
.eventMargin {
margin-top: -85px;
}
}
@media (max-width:748px){
#homepage .carousel .item {
height: auto !important;
}
}
@media screen and (min-width: 766px) and (max-width:1024px){
.carousel-caption{
right:20%;
left:15%;
top:-4%;
}
.titleSlide, h1{
font-size: 33px !important;
}
.content1{
font-size:20px !important;
}
}
@media screen and (min-width: 766px) and (max-width:1024px) and (orientation:landscape){
.carousel-caption{
right:20%;
left:15%;
top:14%;
}
.titleSlide, h1{
font-size: 33px !important;
}
.content1{
font-size:20px !important;
}
}
@media screen and (min-width: 1025px) and (max-width:1280px){
.carousel-caption{
right:20%;
left:20%;
top:20%;
}
}
@media (min-width:749px) and (max-width:767px){
#homepage .carousel .item {
height: auto !important;
/*margin-top:71px;*/
}
}
@media screen and (min-width:768px) and (max-width:991px) and (-webkit-min-device-pixel-ratio:0) {
#homepage .carousel .item {
height: auto !important;
margin-top:154px;
}
}
@media (min-width:783px) and (max-width:991px){
.eventMargin{
margin-top:-200px;
}
.image-margin-top2 {
margin-top: 60px !important;
}
}
@media (max-width:767px){
.image-margin-top2 {
margin-top: 176px !important;
}
}
@media (min-width:768px) and (max-width:782px){
.image-margin-top2 {
margin-top: 62px !important;
}
.eventMargin{
margin-top: -200px;
}
}
@media (min-width:992px){
.image-margin-top2 {
margin-top: 57px !important;
}
}
@media (min-width:992px) and (max-width:1024px){
#homepage .carousel .item {
height: auto !important;
margin-top:20px;
}
}
我已使用以下站点针对 iPhone 和 iPad,但它对 iphone 或 iPad 没有影响:http://stephen.io/mediaqueries/。图像继续倾斜。
有没有办法检测网站何时显示在 iphone 和 ipad 上。一旦检测到,调用另一个仅适用于 iphone 和 ipad 的 css 文件?
我能够找到一行代码来检测它是否在 iphone 上,但不确定如何为 iphone 和 ipad 修改它。我做了以下操作,但它似乎没有检测到是否检测到 iphone 或 ipad:
<script language=javascript>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
<link rel="stylesheet" href="/Regal-en-us/includes/themes/MuraBootstrap3/assets/bootstrap/css/iphone.css">
}
</script>
任何帮助将不胜感激。
谢谢
更新
我使用以下方法来检测用户使用的是 ipad 还是 iphone:
<script language=javascript>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', '<link rel="stylesheet" href="/includes/themes/MuraBootstrap3/assets/bootstrap/css/iphone.css">');
alert("Hello1.1!");
}
</script>
它确实检测到了 iphone 和 ipad。但是,没有检测到我正在做的样式。以下是我为 iphone 和 ipad 设置轮播图像样式的样式:
#homepage .carousel .item {
height: auto !important;
}
#homepage .carousel .item img {
min-width: 100% !important;
max-width: 100% !important;
height: auto !important;
position: relative !important;
}
.carousel-indicators {
bottom: 2%;
}
/* Portrait and Landscape iphone and ipad*/
/*@media only screen
and (min-device-width: 375px)
and (max-device-width: 760px)
and (-webkit-min-device-pixel-ratio: 2) {
#homepage .carousel .item {
height: 139px !important;
margin-top:285px !important;
}
}*/
@media screen and (max-width:768px) and (orientation:portrait) and (-webkit-max-device-pixel-ratio:0) {
#homepage .carousel .item img {
/*min-width: 100% !important;
/*width: 100% !important;*/
height: 293px !important;*/
position: relative !important;
margin-top: 200px;
}
}
如您所见,它没有检测到媒体查询,但它正在被 IPAD 和 IPHONE 识别,因为警报消失了。
任何帮助将不胜感激。
更新:
此时,我只想在 iphone 和 ipad 上看起来不错。我已经为此工作了一段时间,但没有任何解决方案或进展
【问题讨论】:
-
我想如果你在里面再扔几个
!important就会解决你的问题。 -
@hungerstar 猜你的意思是我应该删除 !important?
-
@hungerstar:好的。但是为什么它只会出现在 IPHONES 和 IPADS 中。但是对于其他设备和台式机,它工作正常吗?我已经查看了 css,并且有些东西影响了图像,但它们已被删除,但它仍然出现
-
您在使用自己的旋转木马/滑块吗?还是别人的?
-
我正在使用 MURA 的 cms,我对其进行了修改,以使滑块图像具有共鸣性。它适用于台式机和安卓设备,但不适用于 iphone 或 ipad
标签: javascript jquery css iphone ipad