我希望flex项目居中,但是当我们有第二行时,将5(从下面的图像)下调到1并且不在父项中居中.
这是我的一个例子:
ul {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin: 0;
padding: 0;
}
li {
list-style-type: none;
border: 1px solid gray;
margin: 15px;
padding: 5px;
width: 200px;
}
Run Code Online (Sandbox Code Playgroud)
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我有一个简单的问题.以下代码适用于所有标记:
$('*').click(function(e) {
alert(1);
});
Run Code Online (Sandbox Code Playgroud)
但是,当我为id为"content"的div尝试此代码时:
$('#content').click(function(e) {
alert(1);
});
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?
我的问题如下.我正在使用Symfony的Sonata Admin.在Admin部分中,当我尝试创建实体时,单击添加按钮(拼写为"Ajouter")时不会显示任何内容:
我收到以下错误:Call to a member function getName() on a non-object
在chrome控制台中
这是我的实体层次结构的方式,我有三个以下列方式链接在一起的对象:
Video ---OneToOne--> String ---OneToMany--> LocalizedString
Run Code Online (Sandbox Code Playgroud)
简单地说,我有一个视频将有一个标题,这个标题将被翻译.这是我的实体:
LocalizedString
OSC\UtilsBundle\Entity\LocalizedString:
type: entity
table: null
repositoryClass: OSC\UtilsBundle\Entity\LocalizedStringRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
locale:
type: string
length: '20'
content:
type: string
length: 255
manyToOne:
parent:
targetEntity: String
mappedBy: localizedObjects
lifecycleCallbacks: { }
Run Code Online (Sandbox Code Playgroud)
串
OSC\UtilsBundle\Entity\String:
type: entity
table: null
repositoryClass: OSC\UtilsBundle\Entity\StringRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
oneToMany:
localizedObjects:
targetEntity: LocalizedString
mappedBy: parent …
Run Code Online (Sandbox Code Playgroud) 我正在使用SonataAdmin(和Symfony2)来管理我的实体.我在一个步骤和许多任务之间有一个oneToMany关系.由于一个步骤可以包含许多任务,因此当我创建一个步骤时,我希望能够创建许多任务,并且我希望将这些任务链接到此步骤.为此,我创建了所有正确的管理类(一个用于Task,一个用于Step).
这就是我做的那些导致我的问题.当我尝试创建一个Step时,我可以创建任务甚至重新排序它们,这很棒,并且全部由SonataAdminBundle完成.当我单击"保存"时,所有内容都保存在数据库中,但在数据库中,步骤的ID未在"任务"行中设置.因此,任务没有链接到步骤...
这是我的Step的管理类:
<?php
// src/Acme/DemoBundle/Admin/PostAdmin.php
namespace IMA\ProcessManagementBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class StepAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name', 'text', array('label' => 'Nom de l\'étape'))
->add('tasks', 'sonata_type_collection', array(), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'positionNumber'
))
->add('positionNumber', 'integer', array('label' => 'Position'))
;
}
// Fields to be shown on filter forms
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('name')
;
} …
Run Code Online (Sandbox Code Playgroud) 当用户插入空标记时,ckeditor存在问题:
(在html soucre模式下)
<a href="fds" class="doIt"></a>
Run Code Online (Sandbox Code Playgroud)
当他按下源然后再返回时,标签"A"消失了.我做了一点研究,我发现这种情况发生了,因为ckeditor.js中有一个非常复杂的函数来检查元素中是否有值.如果没有,则ckeditor丢弃标签.
我需要使用google-api-php-client.为此,我将Google的github存储库添加到了我的composer.json中.
"repositories": [
{
"type": "package",
"package": {
"name": "google/google-api-php-client",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/google/google-api-php-client.git",
"reference": "master"
},
"autoload" :{
"classmap": ["src"]
}
}
}
]
Run Code Online (Sandbox Code Playgroud)
...
"require" : {
...
"google/google-api-php-client": "dev-master"
}
Run Code Online (Sandbox Code Playgroud)
一切都安装正确,我有以下目录结构:
/vendor
/google
/google-api-php-client
/examples
/src
/Google
Client.php
Run Code Online (Sandbox Code Playgroud)
当我在Controller中创建对象时,执行以下操作:
$client = new \Google_Client();
Run Code Online (Sandbox Code Playgroud)
找到路径和类.但是,我收到以下错误:
ContextErrorException: Warning: require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory in /Users/etienne/Developpement/Ima-Tech/Clients/lesoptions/vendor/google/google-api-php-client/src/Google/Client.php line 18
Run Code Online (Sandbox Code Playgroud)
在我的Client.php文件中,我在文件的开头有以下内容:
require_once 'Google/Auth/AssertionCredentials.php';
Run Code Online (Sandbox Code Playgroud)
如果我将行更改为:
require_once 'Auth/AssertionCredentials.php';
Run Code Online (Sandbox Code Playgroud)
一切都适合这种包容.但是,我不想require_once
在google-api-php-client项目的每个文件中更改每个文件.我确定有一种方法可以改变包含路径或者某些东西,因此我想知道如何判断命名空间"Google"是当前目录?
编辑1:我猜这可能是因为这个项目(google-api-php-client)不使用命名空间...
我extend
在插件中使用jQuery 来覆盖默认参数.但是,我有一个问题.
这是我的默认设置数组:
slider.settings = {
background: {
animation : {
direction : 'horizontal',
increment : 15 //can be any number
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我想覆盖direction
参数.这是我将使用合并的数组extend
:
settingsToOverwrite = {
background:{
animation:{
direction:'vertical'
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我合并了两个:
slider.settings = $.extend(slider.settings, options)
Run Code Online (Sandbox Code Playgroud)
我可以看到方向值已更新.但是,增量不再存在.我知道为了避免这个问题,我只能在第一级设置参数,但我看到了更多的代码清晰度.有办法吗?如果没有,我会将所有内容改为只有一层深.
我们先来描述一下我的情况.我正在使用Symfony2,我的实体之间的关系有问题.
我有两个链接在一起的实体.这两个实体是AssociationQuestion
和AssociationPossibleAnswer
.我目前正在创建一个问题软件,其中必须将左侧的一个可能答案与右侧的另一个可能答案相关联,例如在以下示例中:
目前,我正计划在类中使用两个属性来AssociationQuestion
保存许多AssociationPossibleAnswer
对象.第一个数组将包含左侧可能的答案,第二个数组将包含右侧可能的答案.
因此,对我来说,看起来我将有两个oneToMany关系 AssociationQuestion
AssociationQuestion:
oneToMany:
possibleAnswersLeft:
targetEntity: AssociationPossibleAnswer
mappedBy: associationQuestion
possibleAnswersRight:
targetEntity: AssociationPossibleAnswer
mappedBy: associationQuestion
Run Code Online (Sandbox Code Playgroud)
然后,在AssociationPossibleAnswer
,我会有一个ManyToOne关系:
AssociationPossibleAnswer:
manyToOne:
associationQuestion:
targetEntity: AssociationQuestion
Run Code Online (Sandbox Code Playgroud)
问题是我在尝试验证我的学说时遇到以下错误.似乎你不能像我希望的那样将两个实体链接到一个......
* The field AssociationQuestion#possibleAnswersLeft is on the inverse side of a bi-directional relationship, but the specified mappedBy association on the target-entity AssociationPossibleAnswer#associationQuestion does not contain the required 'inversedBy=possibleAnswersLeft' attribute.
* The field AssociationQuestion#possibleAnswersRight is on the inverse side of a bi-directional relationship, but the specified mappedBy …
Run Code Online (Sandbox Code Playgroud) 我正在创建一个包含许多不同问题的清道夫编辑器.而且,每个问题可以是不同类型的.因此,我有一系列问题,我做了一个ng-repeat来显示所有问题.
为此,我有一个代表问题的javascript对象.这个问题可以通过不同的问题类型继承.
我有一个特定的问题类型,即slidingPuzzle
需要上传图像.我的问题到了这里,我希望能够在输入文件发生变化时调用此对象内的函数.
我想在这里强调它不能是在范围内声明的一般函数!
这是我的结构的样子(http://plnkr.co/edit/lnJ8rAlpP0xJ3aM2HZ7o?p=preview):
HTML:
<div class="question" ng-repeat="question in scavengerHunt.questions">
<div class="chooseQuestionType">
Question type:
<select ng-change="question.setChild()" ng-model="question.subClass">
<option value="slidingPuzzleQuestion">slidingPuzzleQuestion</option>
</select>
</div>
<div class="questionContainer">
<div class="puzzleContainer">
<input type="file" name="image" id="puzzleContainerImage" ng-file-select="question.child.imageFileSelected()">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
AngularJS模型:
var scavengerHuntApp = angular.module('scavengerHuntApp', []);
scavengerHuntApp.controller('QuestionsCtrl', function ($scope) {
function ScavengerHunt() {
var self = this;
self.questions = [];
self.addQuestion = function(question) {
self.questions.push(question);
}
}
function Question() {
var self = this;
self.id = 0;
self.subClass = "slidingPuzzleQuestion";
self.child = ""; …
Run Code Online (Sandbox Code Playgroud) 我目前正在使用AVCaptureStillImageOutput
以获得全分辨率图片。我还可以使用以下代码获取 exif 元数据:
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
CFDictionaryRef metaDict = CMCopyDictionaryOfAttachments(NULL, imageSampleBuffer, kCMAttachmentMode_ShouldPropagate);
CFMutableDictionaryRef mutableDict = CFDictionaryCreateMutableCopy(NULL, 0, metaDict);
NSLog(@"test attachments %@", mutableDict);
// set the dictionary back to the buffer
CMSetAttachments(imageSampleBuffer, mutableDict, kCMAttachmentMode_ShouldPropagate);
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[self.delegate frameReadyToSave:image withExifAttachments: mutableDict];
}];
Run Code Online (Sandbox Code Playgroud)
元数据位于mutableDict
变量中。现在,我想用元数据将这张图片保存在两个不同的地方。我想将它保存在磁盘上的应用程序文件夹和照片库中。
现在,我尝试使用以下另一种方法保存图像(您看到的图像变量是自定义对象):
NSData* imageData = UIImageJPEGRepresentation(image.image, 1.0f);
[imageData writeToFile:image.filePath atomically:YES];
UIImageWriteToSavedPhotosAlbum(image.image, nil, nil, nil);
Run Code Online (Sandbox Code Playgroud)
现在,图像已正确保存,但不包含任何 Exif 元数据。
从我读到的内容来看,我需要使用 PHPhotoLibrary 来做到这一点,但文档对此并不太啰嗦。这是我发现的:
[[PHPhotoLibrary sharedPhotoLibrary] …
Run Code Online (Sandbox Code Playgroud) jquery ×4
php ×4
symfony ×4
javascript ×3
sonata-admin ×2
angularjs ×1
ckeditor ×1
css ×1
css3 ×1
doctrine-orm ×1
fckeditor ×1
flexbox ×1
google-api ×1
html ×1
ios ×1
ios9 ×1
many-to-one ×1
objective-c ×1
one-to-many ×1