如何摆脱媒体查询

时间:2016-10-09 17:07:56

标签: css media-queries

我一直试图摆脱顶级&该标题的右边距。我试过保证金:0&保证金:无 它没有奏效。任何建议将不胜感激。

 p.title {
  font-family: 'Germania One';
  font-style: normal;
  color: #FFF;
  font-size: 150px;
  Position:absolute;
  width:100%;
  z-index:1000;
  text-align:left;
  margin-top: 300px;
  margin-bottom: 0px;
  margin-left:200px;
}

@media (min-width:320px) and (max-width:425px) {

p .title{ 
  position:none; margin: 0 ; 
}

4 个答案:

答案 0 :(得分:2)

媒体查询中的选择器无法覆盖媒体查询之前的选择器,因为它们不相同。将媒体查询中的选择器从<?php //Shopping Cart (./cart.php) //GET -> id of the product. if (isset($_GET['articulo'])) { $id_tutorial = $_GET['articulo'] ?: ''; //If the session is defined for Shop Cart. if (isset($_SESSION['carrito'])) { //Get data from session. $arreglo = $_SESSION['carrito']; $encontro = false; for ($i=0; $i<count($arreglo); $i++) { //checking if product has already been added to the cart. if ($arreglo[$i]['Id'] == $_GET['articulo']) { $encontro = true; } } //If find product is false, update de array session (Shop cart). if ($encontro == false) { //Reset $titulo = ""; $precio = 0; $icon = ""; //Get data from DB. $stmt = $c->prepare("SELECT titulo,precio,icon FROM tutoriales WHERE page=? and status=1"); $stmt->bind_param("i",$_GET['articulo']); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($titulo,$precio,$icon); while ($stmt->fetch()) { //New data for array. $datosnuevos = ['Id' => $_GET['articulo'], 'Titulo' => $titulo, 'Precio' => $precio, 'Icon' => $icon, 'Cantidad' => 1 ]; //array_push($arreglo, $datosnuevos); $arreglo[] = $datosnuevos; $_SESSION['carrito'] = $arreglo; //Count total of products added to the cart. $data = $_SESSION['carrito']; $value_carrito = count($data); $_SESSION['compras'] = $value_carrito; } $stmt->close(); } else { $stmt->close(); } } } else { //If session is not defined for Shop Cart, that is to say that the card is in 0 productos. //Reset. $titulo = ""; $precio = 0; $icon = ""; //Get data from DB. $stmt = $c->prepare("SELECT titulo,precio,icon FROM tutoriales WHERE page=? and status=1"); $stmt->bind_param("i",$_GET['articulo']); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($titulo,$precio,$icon); while ($stmt->fetch()) { //Started the array for Shop Cart. $arreglo[] = ['Id' => $_GET['articulo'], 'Titulo' => $titulo, 'Precio' => $precio, 'Icon' => $icon, 'Cantidad' => 1 ]; $_SESSION['carrito'] = $arreglo; //Count total of products added to the cart. $data = $_SESSION['carrito']; $value_carrito = count($data); $_SESSION['compras'] = $value_carrito; } $stmt->close(); } else { $stmt->close(); } } } ?> 更改为p .title,它将起作用。

p.title中的space combinator)表示选择器的第二部分是第一部分的后代,而链接选择器没有空格意味着选择器适用于相同的元素。

因此,CSS selector会选择包含p.title类的任何<p>标记,而title会选择类p .title的任何元素作为{title的后代{1}}元素。

以下是CSS combinators的列表。

答案 1 :(得分:0)

您在媒体查询中写了p .title(带空格)而不是p.title

答案 2 :(得分:0)

你写了一个错字:

@media (min-width:320px) and (max-width:425px) {

    p.title{ /* No Space */
      position:none; margin: 0 ; 
    }
}

答案 3 :(得分:0)

//从p .title {}中删除空格并将媒体查询添加为 -

@media(min-width:320px)和(max-width:425px){

p.title{ 
  position:none; 
margin-top: 0; 
margin-right: 0; 
}

}