如何创建覆盖另一种CSS样式的CSS样式

时间:2016-05-25 18:54:05

标签: html css

我有两种CSS样式,除了一个特定的宽度之外几乎相同。而另一个没有。如何创建一个继承另一个CSS样式但覆盖属性的CSS样式?

`"//test-fps/Sales/test1.xlsx"`



    <?php 

$connect = mysqli_connect("localhost", "root", "pass","server");

include ("PHPExcel/IOFactory.php");


$html = "<table border='1'>";

$objPHPExcel = PHPExcel_IOFactory::load("//test-fps/Sales/test1.xlsx");

foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
    $highestRow = $worksheet->getHighestRow();
    for ($row=2; $row<=$highestRow; $row++)
    {
        $html.="<tr>";
        $ticketnumber = mysqli_real_escape_string($connect,$worksheet->getCellByColumnAndRow(0,$row)->getValue());
        $status = mysqli_real_escape_string($connect,$worksheet->getCellByColumnAndRow(1,$row)->getValue());
        $sql = "INSERT INTO tbl_excel(ticketnumber, status) VALUES ('".$ticketnumber."', '".$status."')";
        mysqli_query($connect, $sql);
        $html.='<td>' .$ticketnumber . '</td>';
        $html.= '<td>' .$status. '</td>';
        $html.= "</tr>";
    }
}
$html .= "</table>";
echo $html;
echo '<br />Data Inserted';
?>

3 个答案:

答案 0 :(得分:1)

你可以这样试试

在上面的两个类中,未定义宽度

.FirstStyle, .SecondStyle
{
    margin: 0px 0px 0px 8px;
    position: relative;
    display: inline-block;

    height: 29px;
    width: 5px;

    float: left;
}

这里只为FirstStyle Class定义宽度..(无论如何,这个类低于其他类可以覆盖上面指定的最终宽度)

.FirtsStyle
{
    width: 5px;
}

答案 1 :(得分:0)

如何创建一个继承另一个CSS样式但覆盖属性的CSS样式?

随后的css样式会自动覆盖前面的属性,因此只需将属性添加到要覆盖的属性下面,它就会继承除指定的新样式之外的所有内容。

示例:

HTML:

<div class="someClass anotherClass">
   ....
</div>

CSS:

.someClass {
    width: 100px;
    color: green;
}
.anotherClass {
    width: 200px; <-- This will override the above values
    color: red;
}
.someClass {
    width: 450px !important; <-- The !important tag will override both suceeding as well as preceeding properties
}
.someClass {
    width: 500px; <-- This will override the first two styling properties
}

答案 2 :(得分:0)

您可以计算CSS specificity value

enter image description here

  1. 如果元素具有内联样式,则会自动获胜(1,0,0,0 分)
  2. 对于每个ID值,请应用0,1,0,0 points
  3. 对于每个类值(或伪类或属性选择器),请应用 0,0,1,0分
  4. 对于每个元素引用,应用0,0,0,1 point
  5. 备注

    1. 通用选择器(*)没有特异性值(0,0,0,0)
    2. 伪元素(例如 func configureCell(post: Post, img: UIImage?, img2: UIImage?) { self.post = post likeRef = DataService.ds.REF_USER_CURRENT.childByAppendingPath("likes").childByAppendingPath(post.postKey) self.descriptionText.text = post.postDescription self.descriptionText.scrollRangeToVisible(NSMakeRange(0, 0)) self.likes = post.likes self.likesLbl.text = "\(post.likes) likes" self.postTitle.text = post.postTitle self.postLocation.text = post.postLocation self.username.text = post.username self.postKeyLbl.text = post.key self.lat = post.lat self.long = post.long if post.postImgUrl != nil { if img != nil { self.showcaseImg.image = img } else { request = Alamofire.request(.GET, post.postImgUrl!).validate(contentType: ["image/*"]).response(completionHandler: { request, response, data, err in if err == nil { let _img = UIImage(data: data!)! self.showcaseImg.image = img FeedVC.imageCache.setObject(_img, forKey: self.post.postImgUrl!) } else { print(err.debugDescription) } }) } } else { self.showcaseImg.hidden = true } if post.userImgUrl != nil { if img2 != nil { self.profileImg.image = img2 } else { request = Alamofire.request(.GET, post.userImgUrl!).validate(contentType: ["image/*"]).response(completionHandler: { request, response, data, err in if err == nil { let _img2 = UIImage(data: data!)! self.profileImg.image = img2 FeedVC.imageCache.setObject(_img2, forKey: self.post.userImgUrl!) } else { print(err.debugDescription) } }) } } else { print("no image") } likeRef.observeSingleEventOfType(.Value, withBlock: { snapshot in if snapshot.value is NSNull { self.likesImg.image = UIImage(named: "heart") } else { self.likesImg.image = UIImage(named: "heart-filled") } }) let getUid = NSUserDefaults.standardUserDefaults().valueForKey(KEY_UID) if String(getUid!) == (self.post.postUid) { editBtn.hidden = false delBtn.hidden = false let usernameDefaults = NSUserDefaults.standardUserDefaults().valueForKey("username") if usernameDefaults != nil { username.text = String(usernameDefaults!) } let checkIfImageChanged = NSUserDefaults.standardUserDefaults().boolForKey("imgIsChanged") if checkIfImageChanged == true { self.changePost() NSUserDefaults.standardUserDefaults().setBool(false, forKey: "imgIsChanged") } } else { editBtn.hidden = true delBtn.hidden = true } mapVC.markerTitle = postTitle.text mapVC.markerSnippet = postLocation.text mapVC.markerLat = lat mapVC.markerLong = long } )获得0,0,0,1不同于它们 获得0,0,1,0
    3. 的伪阶级弟兄
    4. 伪类:first-line本身不会增加任何特异性,只会增加特征 在它的括号内。
    5. 附加CSS属性值的:not()值是自动的 赢得。它甚至覆盖了标记中的内联样式。唯一的办法 可以覆盖!important值是另一个!important 后来在CSS中声明的规则具有相同或极大的特异性 另有价值。您可以将其视为添加1,0,0,0,0 特异性值