小编Joe*_*ano的帖子

是否可以使用CSS创建此形状(两个部分圆连接在一起)?

我试图用CSS完成两个div的边框:

期望的结果

我尝试过使用border-radius,但两个部分圆圈没有压在一起:http://jsfiddle.net/uwz6L79w/

 .left {
   position: absolute;
   left: 0;
   top: 0;
   width: 100px;
   height: 100px;
   border-width: 4px;
   border-color: black white black black;
   border-style: solid;
   border-radius: 60px
 }
 .right {
   position: absolute;
   left: 104px;
   top: 0;
   width: 100px;
   height: 100px;
   border-width: 4px;
   border-color: black black black white;
   border-style: solid;
   border-radius: 60px;
 }
Run Code Online (Sandbox Code Playgroud)
<div class="left"></div>
<div class="right"></div>
Run Code Online (Sandbox Code Playgroud)

我可以进一步将它们压在一起,但我必须让另一个div重叠,如下所示:http://jsfiddle.net/uwz6L79w/1/.

.left {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
  border-width: 4px;
  border-color: black …
Run Code Online (Sandbox Code Playgroud)

html css html5 css3 css-shapes

42
推荐指数
4
解决办法
3859
查看次数

如何设置最大宽度百分比和像素?

如何防止div的宽度扩展超过百分比和像素?换句话说,浏览器应计算百分比的像素值,然后选择两个值中的较低者.

如果我将它们设置为这样:{max-width:100px;max-width:20%;}资产管道只选择第二个并忽略第一个.

html css css3 asset-pipeline

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

bcrypt LoadError:无法加载此类文件

我正在尝试为我的Rails应用程序设置登录功能,当我按下登录按钮时,我收到一条bcrypt错误消息:

LoadError in SessionsController#create
cannot load such file -- bcrypt
Run Code Online (Sandbox Code Playgroud)

是否有其他人收到此错误?我有最新版本的bcrypt,我正在按照教程告诉我的做法.

用户模型:我在所谓的错误行周围放了星号.

class User < ActiveRecord::Base
  ****has_secure_password****
end
Run Code Online (Sandbox Code Playgroud)

会话控制器:

class SessionsController < ApplicationController
  def new
  end

  def create
    user = User.find_by(id: params[session][:id])
    if user && user.authenticate(params[:session][:password])
      log_in user
      redirect_to root_path
    else
      flash.now[:danger] = 'Invalid'
      render 'new'
    end
  end

  def destroy
  end
end
Run Code Online (Sandbox Code Playgroud)

ApplicationController中:

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  include SessionsHelper
end
Run Code Online (Sandbox Code Playgroud)

SessionsHelper:

module SessionsHelper

  def log_in(user)
    session[:user_id] = user.id
  end
end
Run Code Online (Sandbox Code Playgroud)

的Gemfile:

gem 'bcrypt', '~> 3.1.7'
Run Code Online (Sandbox Code Playgroud)

会话/新视图:

<div …
Run Code Online (Sandbox Code Playgroud)

ruby load ruby-on-rails bcrypt ruby-on-rails-4

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

Rails检测移动设备的方式?

是否有"轨道方式"来检测用户是否正在使用移动设备?我的意思是我可以在erb中使用的方法,如下所示:

<% if mobile? %>
Run Code Online (Sandbox Code Playgroud)

ruby mobile ruby-on-rails

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

我可以使用符合特定条件的多个关联记录查询记录吗?

我有两张桌子Show,Character.每个Show has_many Characters.

class Show < ActiveRecord::Base
  has_many :characters

class Character < ActiveRecord::Base
  belongs_to :show
Run Code Online (Sandbox Code Playgroud)

我想要做的是返回与符合特定条件的多个字符相关联的Show的结果.

例如,我希望能够返回一个包含蝙蝠侠和罗宾字符的节目列表.不是蝙蝠侠或罗宾,蝙蝠侠和罗宾.

所以查询应该是这样的

Show.includes(:characters).where(characters: {'name = ? AND name = ?', "Batman", "Robin"})
Run Code Online (Sandbox Code Playgroud)

但这会返回错误.是否有一个可行的语法?

UPDATE

查询

Show.includes(:characters).where('characters.name = ? AND characters.name = ?', "Batman", "Robin")
Run Code Online (Sandbox Code Playgroud)

返回值0,即使有明确的显示与蝙蝠侠和罗宾相关联.

ruby mysql sql ruby-on-rails

17
推荐指数
2
解决办法
1328
查看次数

尝试使用 Oauth 1.0 获取 Twitter request_token 不断给出“215 Bad Authentication”错误

I'm trying to get an Oauth request token from Twitter - I'm following their guide (links below) and I've gone over every single step about 10 times but I cannot figure out why I'm getting this error:

{\"errors\":[{\"code\":32,\"message\":\"Could not authenticate you.\"}]}

They use Oauth 1.0. I'm supposed to combine all the percent-encoded params in my request, percent encode them, add the request method (POST) and the request url, use that plus my api key secret to create a signature, and …

ruby twitter oauth hmac twitter-oauth

9
推荐指数
1
解决办法
502
查看次数

Phusion Passenger内部服务器错误

我在我的Linode服务器上使用Apache + Passenger,使用Postgresql-9.4数据库.每隔一段时间,我就会收到以下错误,但是几分钟后它就不可预测并且权限本身没有采取任何措施,因此调试非常困难:

Internal server error
Phusion Passenger has listed more information about the error below.
An error occurred while starting the web application. It sent an unknown response type "".
Run Code Online (Sandbox Code Playgroud)

有没有其他人遇到过这样的错误,或者知道它可能意味着什么?

apache postgresql passenger linode server

8
推荐指数
1
解决办法
1066
查看次数

CSS:在/之后,选择器突然与父div分开定位

我换了一台新电脑,突然间CSS :after:before选择器不再工作了.

真正奇怪的是,:before/:after我之前在其他计算机上添加的选择器在我的新计算机上完全正常显示.但是,即使我将旧代码复制并粘贴到新的div上,我现在添加的任何新内容都不会显示出来.

例如,这一个:

HTML

<div id="wtf"></div>
Run Code Online (Sandbox Code Playgroud)

CSS

#wtf {
    width: 10px;
    height: 20px;
    background: red;
}
#wtf:after {
    content: "";
    position: absolute;
    left: 100px;
    top: 10px;
    width: 20px;
    height: 20px;
    background: blue;
}
Run Code Online (Sandbox Code Playgroud)

此代码在复制并直接粘贴到小提琴中时起作用:(http://jsfiddle.net/rLnrtu0x/)但只有红色框显示在我的本地浏览器上.无论我做什么,蓝框都不会显示.所有其他CSS表现正常.

有谁知道我可能做错了什么?

在Ubuntu 14.04上测试了Mozilla 35.0.1和Chrome 42.0.2311.152(64位).我不能在我的旧电脑上重新测试它,因为它破了,但我之前从未遇到过:before/:after选择器问题.

UPDATE

我刚用检查员找到了选择器.它们实际上是正常显示的,但它们是相对于它们而html不是它们的父div定位的.再次,使用我在计算机更改之前添加的代码,:before/:after选择器相对于父div定位.但是新代码即使是复制粘贴,也会将选择器相对于html.为什么会这样?

html css css3 pseudo-element

8
推荐指数
1
解决办法
1358
查看次数

IDE0006警告和许多其他新的Cross Platform Xamarin应用程序,全新安装Visual Studio

我刚刚在运行Windows 10的PC上安装了Visual Studio 2017,并创建了一个名为"trial"的Cross Platform Xamarin应用程序(Blank和PLC).马上,错误框中出现以下警告:

IDE0006 - Error encountered while loading the project. Some project pfeatures, such as full solution alaysisis for the failed project and projects that depend on it, have been disabled.

To see what caused the issue, please try below.

1. Close Visual Studio
2. Open a Visual Studio Developer Command Prompt
3. Set environment variable "TraceDesignTime" to true (set TraceDesignTime=true)
4. Delete .vs directory/.suo file
5. Restart VS from the command prompt you set the …
Run Code Online (Sandbox Code Playgroud)

visual-studio xamarin.android xamarin xamarin.forms visual-studio-2017

8
推荐指数
1
解决办法
1092
查看次数

主目录中的Rails命令导致"i18n gem not available"错误

我在我的Ubuntu主目录中,试图创建一个新的rails应用程序rails new,但我收到此错误:

i18n宝石不可用.请将其添加到您的Gemfile并运行bundle install

我运行的任何rails命令都会出错.我真的很困惑,因为我不在应用程序中.我就在我的主目录中.没有gemfile.我尝试将'i18n'安装到我的主目录中gem install 'i18n',并且它有效,但我仍然遇到了这个错误.

我之前在我的主目录中从未遇到过rails命令的任何问题.当我cd进入我的个人应用程序时,所有与rails相关的工作正常.这是怎么回事?

此外,我现在在所有现有的rails应用程序中遇到同样的错误.铁轨突然变得依赖于那颗宝石了吗?或者可以删除我的主目录中的gem以某种方式使其在我的应用程序中不可用?


UPDATE

我尝试gem cleanup rails并重新安装,但没有任何改变.结果如下:

$ gem cleanup rails
  Cleaning up installed gems...
  Attempting to uninstall rails-4.0.10
  Successfully uninstalled rails-4.0.10
  Attempting to uninstall rails-4.2.1
  Successfully uninstalled rails-4.2.1
  Attempting to uninstall rails-4.2.4
  Successfully uninstalled rails-4.2.4
  Attempting to uninstall rails-5.0.1
  Successfully uninstalled rails-5.0.1
  Attempting to uninstall rails-5.0.2
  Successfully uninstalled rails-5.0.2
  Attempting to uninstall rails-5.0.3
  Successfully uninstalled rails-5.0.3
  Attempting to uninstall rails-5.0.4
  Successfully uninstalled rails-5.0.4
  Clean …
Run Code Online (Sandbox Code Playgroud)

ruby ubuntu rubygems ruby-on-rails rails-i18n

8
推荐指数
1
解决办法
2349
查看次数