小编Mac*_*ito的帖子

如何将浮动元素居中?

我正在实施分页,它需要集中.问题是链接需要显示为块,因此需要浮动它们.但是,text-align: center;对他们不起作用.我可以通过给左边的包装div填充来实现它,但是每个页面都有不同的页面数,所以这不起作用.这是我的代码:

.pagination {
  text-align: center;
}
.pagination a {
  display: block;
  width: 30px;
  height: 30px;
  float: left;
  margin-left: 3px;
  background: url(/images/structure/pagination-button.png);
}
.pagination a.last {
  width: 90px;
  background: url(/images/structure/pagination-button-last.png);
}
.pagination a.first {
  width: 60px;
  background: url(/images/structure/pagination-button-first.png);
}
Run Code Online (Sandbox Code Playgroud)
<div class='pagination'>
  <a class='first' href='#'>First</a>
  <a href='#'>1</a>
  <a href='#'>2</a>
  <a href='#'>3</a>
  <a class='last' href='#'>Last</a>
</div>
<!-- end: .pagination -->
Run Code Online (Sandbox Code Playgroud)

为了得到这个想法,我想要的是:

替代文字

css center css-float

342
推荐指数
7
解决办法
81万
查看次数

如何更改材质中的md-icon大小

这个问题来自material2 github repo https://github.com/angular/material2/issues/4422#issuecomment-300309224

我仍然有问题来设置包装在自定义组件中的材质组件.

我有一个<logo>包含的组件<md-icon svgIcon="logo"></md-icon>

加入

:host { 
   .mat-icon {
    width: 100px;
    height: 100px;
    font-size: 56px;
  }
}
Run Code Online (Sandbox Code Playgroud)

不适用于我的自定义组件中的材质组件

angular-material angular

42
推荐指数
6
解决办法
5万
查看次数

jquery .hide().fadeIn()

这是我的代码:

$('.items').html(response).hide().fadeIn();
Run Code Online (Sandbox Code Playgroud)

问题是当加载它时页面"跳"起来,因为.hide()..还有其他方法可以做到这一点吗?

jquery hide fadein

10
推荐指数
2
解决办法
2万
查看次数

使用npm脚本将*.js和*.css注入index.html

我正在研究从gulp/grunt切换到仅使用npm脚本.但我真的无法解决如何从给定路径获取*.js和*.css并将其添加到index.html文件中.

我必须通过"index.js"文件添加它,还是可以做类似......

"scripts": {
 "inject": "inject src/app/*.js",
},
Run Code Online (Sandbox Code Playgroud)

然后它会将它添加到我的index.html中,我已经指定它...

/* inject:js */
Run Code Online (Sandbox Code Playgroud)

inject script-tag npm

7
推荐指数
1
解决办法
3403
查看次数

使用协议相对URL时加载了什么协议?

我刚开始测试"protocol less Urls"背后的想法.

我要解决的问题是:在https页面上我需要从http加载外部css文件.

以"正常"方式执行此操作会导致失败... css文件被阻止.(现在只用chrome测试).

所以我的问题是:"protocol less urls"会从http/https/both加载文件吗?

url protocols

5
推荐指数
1
解决办法
5119
查看次数

需要在函数中访问服务

我有一个服务(AuthService),我需要在我的restangularInit函数(在我的 app.module.ts 中)中访问它,但我不知道如何访问它,我无法访问它。

\n\n

我试图将它移动到 AppModule 类中,但到那时它\xc2\xb4s 已经晚了。

\n\n

调用服务功能,例如。getToken按预期工作。

\n\n
import { BrowserModule } from \'@angular/platform-browser\';\nimport { NgModule } from \'@angular/core\';\nimport { FormsModule } from \'@angular/forms\';\nimport { HttpModule } from \'@angular/http\';\nimport { MaterialModule } from \'@angular/material\';\nimport { FlexLayoutModule } from "@angular/flex-layout";\nimport { RestangularModule } from \'ng2-restangular\';\n\n// Components\nimport { AppComponent } from \'./app.component\';\nimport { ProductComponent } from \'./components/product/product.component\';\n\n// Services\nimport { AuthService } from \'./services/auth.service\';\n\nexport function restangularInit(RestangularProvider, AuthService) {\n  console.log(AuthService); // this is undefined\n  let token = …
Run Code Online (Sandbox Code Playgroud)

restangular angular2-services angular

5
推荐指数
1
解决办法
4116
查看次数

'HttpEvent <Customer>'类型中不存在属性'data'

我有这样的设置

  • api.service(包装httpClient模块)
  • 客户服务

api服务看起来像这样:

get<T>(url: string, options?) {
return this.httpClient.get<T>(this.apiUrl + url, this.getOptions(options));}
Run Code Online (Sandbox Code Playgroud)

在我的customer.service我有:

    private fetchCustomer(access_token: String): Observable<Customer> {
      const options = { headers: new HttpHeaders({ Authorization: 'Bearer ' + access_token }) };
      return this.http
        .get<Customer>('customers/me', options)
        .map(res => {
          const customer = res.data;
          customer.access_token = access_token;
          return customer;
        })
        .catch(this.handleError.bind(this));
    }
Run Code Online (Sandbox Code Playgroud)

它给了我这个错误:

[ts]
Property 'data' does not exist on type 'HttpEvent<Customer>'.
Property 'data' does not exist on type 'HttpSentEvent'.
Run Code Online (Sandbox Code Playgroud)

get http angular

5
推荐指数
3
解决办法
6145
查看次数

Angular Material(组件)中的条件按钮颜色属性

我有一个需要输入的组件.. @Input() coDeliveryCandidates: DeliverySlotView[];

这在模板中使用:

<ng-container *ngFor="let coDeliverySlotView of (coDeliveryCandidates | async)">
  <button
    mat-raised-button
    [color]=""
  >
    {{ label  }}
  </button>
</ng-container>
Run Code Online (Sandbox Code Playgroud)

color 属性需要一个字符串作为值,我想做一些类似的事情:

[color]="{
  black: coDeliverySlotView.slotId === bookedSlot.slotId,
  grey: !coDeliverySlotView.slotId === bookedSlot.slotId
}"
Run Code Online (Sandbox Code Playgroud)

在这里,我使用与 ngClass 相同的语法,但我想它不支持这种方式..那么还有哪些其他类似的方式呢?:)

conditional-statements angular-material angular-components angular

5
推荐指数
1
解决办法
3893
查看次数

在FormBuilder中使用嵌套对象

所以我有这种形式,它工作正常..但现在我想扩展一些json结构...

https://plnkr.co/edit/aYaYTBRHekHzyS0M7HDM?p=preview

我想要使​​用的新结构看起来像这样(只有地址:已更改):

  email: ['', [Validators.required, Validators.email]],
  password: ['', [Validators.required, Validators.minLength(5)]],
  address: this.fb.array([{
    name: '',
    addressLine1: ['', [Validators.required]],
    city: ['', [Validators.required]],
    postalCode: [Validators.required],
  }]),
Run Code Online (Sandbox Code Playgroud)

但我不断收到错误,如"ERROR TypeError:control.registerOnChange不是函数".想通知这与formControlName缺失有关,但我不希望所有数据都显示..

在输入字段中,我只想显示addressLine1(根本不显示name,city或postalCode).

forms angular2-formbuilder angular

4
推荐指数
1
解决办法
6931
查看次数

SQL查询性能LIKE和wildecards vs. IN

我只是觉得如果这2个查询会有很大的性能差异

SELECT 
  `items_id`, `sport_id`, `sport`, `title`, `url`, 
  `Select3`, `Select6`, `id`, `data`,`image` as image,
  concat('index.php?option=sports&amp;item=',`items_id`,'&amp;p=C108-M108') as count_url
FROM 
  qy9zh_dataitems
WHERE Select6 LIKE '%sport%'
ORDER BY `Select9` DESC LIMIT 0, 4


SELECT 
  `items_id`, `sport_id`, `sport`, `title`, `url`, 
  `Select3`, `Select6`, `id`, `data`,`image` as image,
  concat('index.php?option=sports&amp;item=',`items_id`,'&amp;p=C108-M108') as count_url
FROM 
  qy9zh_dataitems 
WHERE Select6 in ('sport') 
ORDER BY `Select9` DESC LIMIT 0, 4
Run Code Online (Sandbox Code Playgroud)

查询工作得很好..他们两个..只是担心性能:)

编辑:当我做一些测试时,一个奇怪的事情是:

SELECT * FROM qy9zh_dataitems WHERE Select6 in ('kvinna') LIMIT 0, 40000
Run Code Online (Sandbox Code Playgroud)

共计29,051次,查询耗时0.2581秒

SELECT * FROM qy9zh_dataitems WHERE Select6 LIKE ('%kvinna%') LIMIT …
Run Code Online (Sandbox Code Playgroud)

mysql sql performance select sql-like

3
推荐指数
1
解决办法
5368
查看次数