如何将背景图像放在容器中间?

时间:2015-11-02 19:02:13

标签: html css

我会假设这个小提琴会导致狮子的头部位于右侧div的中间位置:

http://jsfiddle.net/v6dc7d17/

为什么不发生这种情况?我该如何做到这一点?我认为.full-half-image { background-position: center center; background-repeat: no-repeat; background-attachment: fixed; background-size: cover; background-color: #000; } 应该这样做。

    var myUIImage : UIImage!
        @IBAction func shareThisApp(sender: AnyObject) {  
            let mailComposeViewController = ShareAppEmail()
            if MFMailComposeViewController.canSendMail() {

//self.presentViewController(mailComposeViewController, animated: true, completion: nil)

//The line below is showing Error: fatal error: unexpected found nil while unwrapping an Optional value
            let imageData = UIImagePNGRepresentation(myUIImage)

            mailComposeViewController.addAttachmentData(imageData!, mimeType: "image/png", fileName: "image.png")
            } else {
                self.showSendMailErrorAlert()

//self.presentViewController(mailComposeViewController, animated: true, completion: nil)
            }
        }
        func ShareAppEmail() -> MFMailComposeViewController {
            let mailComposerVC = MFMailComposeViewController()
            mailComposerVC.mailComposeDelegate = self 

            mailComposerVC.setToRecipients([""])
            mailComposerVC.setSubject("Check this great app")
            mailComposerVC.setMessageBody("Take a look at this new app", isHTML: false)

            return mailComposerVC
        }

1 个答案:

答案 0 :(得分:0)

您已应用background-attachment: fixed;

固定的背景附件相对于视口而不是容器。

据我所知,目前无法使用纯CSS附加相对于其容器的固定背景。