我想通过GoDaddy获得一个域名来与我的Heroku托管网站一起工作.
如何配置我的域名以使用Heroku?
如何将文本居中对齐<img>
优选使用FlexBox?
body {
margin: 0px;
}
.height-100vh {
height: 100vh;
}
.center-aligned {
display: box;
display: flex;
box-align: center;
align-items: center;
box-pack: center;
justify-content: center;
}
.background-image {
position: relative;
}
.text {
position: absolute;
}
Run Code Online (Sandbox Code Playgroud)
<section class="height-100vh center-aligned">
<img class="background-image" src="http://vignette2.wikia.nocookie.net/uncyclopedia/images/f/f8/Stand-out-in-the-crowd-300x300.jpg" />
<div class="text">SOME TEXT</div>
</section>
Run Code Online (Sandbox Code Playgroud)
如何.js.erb
从不属于要呈现的视图的控制器渲染a ?
例如:如何create.js.erb
在我的页面视图中呈现post_controller
?
post_controller.rb
def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render action: 'show', status: :created, location: @post }
format.js #{I think I need something in here?}
else
format.html { render action: 'new' }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end
Run Code Online (Sandbox Code Playgroud) 有人知道如何使用flexbox创建此布局吗?
文本将放在中心,按钮将放在文本和底部之间.
我现在有这个:
.aligner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<div class="aligner">
<h3>SUPERMAN</h3>
<p>FTW</p>
<button>BUTTON</button>
</div>
Run Code Online (Sandbox Code Playgroud)
这会对齐中心的所有内容,但我只希望文本位于中心,而中心和底部之间的按钮.
我正在尝试使用Google Application Default Credentials使用Google API(服务器到服务器)对Node.js应用程序(在App Engine上运行Express)进行身份验证.该应用程序应该使用凭据与Google Analytics进行对话,我已经通过启用了该功能Analytics API
来设置Google Analytics Google Developers Console
.这是我实现的代码:
var google = require('googleapis')
var analytics = google.analytics('v3')
app.post('/getAnalyticsData', (req, res) => {
google.auth.getApplicationDefault(function(err, authClient) {
if (err) {
/* Handle error */
}
if (authClient) {
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
authClient = authClient.createScoped(['https://www.googleapis.com/auth/analytics.readonly'])
}
analytics.data.ga.get({
'auth': authClient,
'ids': 'ga:VIEW_ID',
'metrics': 'ga:pageviews,ga:sessions',
'start-date': '2017-01-01',
'end-date': '2017-03-09'
}, function(err, response) {
if (err) {
console.log("Analytics error: ", err)
}
if (response) {
console.log("YAY! …
Run Code Online (Sandbox Code Playgroud) google-app-engine google-api google-authentication google-oauth
我正在使用simple_form创建一个表单,并且我正在尝试将所有输入放在同一行上(我希望所有元素在呈现的页面上水平内联).
我已经搜索了几个小时的问题,但我找不到有效的解决方案.
simple_form代码:
<%= simple_form_for(@post, :html => {:class => 'form-inline' }) do |f| %>
<%= f.input :link, label: false, placeholder: "here..." %>
<%= f.input :type, as: :radio_buttons, collection: [['<span class="add-on"><i class="icon-on icon-white"></i></span>'.html_safe, '0'], ['<span class="add-on"><i class="icon-off icon-white"></i></span>'.html_safe, '1'], ['<span class="add-on"><i class="icon-on icon-white"></i> + <i class="icon-of icon-white"></i></span>'.html_safe, '2']], item_wrapper_class: 'inline', label: false %>
<%= button_tag(type: 'submit', class: "btn btn-inverse") do %>
<i class="icon-ok icon-white"></i>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
对此有何解决方案?
我已经阅读了与此标题相关的大多数其他帖子,但找不到解决方案。
我有三个文件(我知道整个程序没有任何意义,仅用于测试目的):
main.cpp
#include "Animal.h"
Animal ape;
int main(int argc, char *argv[]){
ape.getRace();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
动物
class Animal{
public:
int getRace();
private:
int race;
};
Run Code Online (Sandbox Code Playgroud)
动物.cpp
#include "Animal.h"
Animal::Animal(){
race = 0;
}
int Animal::getRace(){
race = 2;
return race;
}
Run Code Online (Sandbox Code Playgroud)
当我运行main.cpp文件时,出现此错误:
Undefined symbols for architecture x86_64:
"Animal::getRace()", referenced from:
_main in main-oTHqe4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Finished in 0.1s with exit …
Run Code Online (Sandbox Code Playgroud) 我有一些接近这个:
<div class="batman-pictures">
<a><img /></a>
<a><img /></a>
<a><img /></a>
<a><img /></a>
<a><img /></a>
<a><img /></a>
</div>
Run Code Online (Sandbox Code Playgroud)
我不知道<a><img /></a>
将生成多少(我从API中获取它们),并且我想删除前三个(n)之后的所有元素<a><img /></a>
.我怎么能在jQuery中做到这一点?
在 React 中,我试图在加载特定组件时动态添加<script>
a 。<head>
我之前曾将此代码用于类似的事情(使用更简单的脚本):
componentWillMount() {
var script= document.createElement('script');
script.src = "SOME_URL";
document.body.appendChild(script);
}
Run Code Online (Sandbox Code Playgroud)
但是我现在尝试注入 head 的代码包含缩小的 js (它是 Google Analytics 内容实验代码),如下所示:
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='XXXXXXXXX-Y',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return;
function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
'<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
'://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
</script><script>utmx('url','A/B');</script>
<!-- End of Google Analytics Content Experiment code -->
Run Code Online (Sandbox Code Playgroud)
我如何动态地将其注入<head>
?
更新:我最终使用了他们的客户端解决方案。
当我悬停此链接时:
<div id="withLibre">
by <%= link_to p.user.username, "#", {class: "username_link"} %><%=time_ago_in_words(p.created_at) %> ago
</div>
Run Code Online (Sandbox Code Playgroud)
...背景颜色为黑色,即使我设置background-color
为none
或另一种颜色.我能够改变color
,但不是background-color
.CSS在这里介绍:
.username_link:hover{
background-color: none;
color: #34DDDD;
text-decoration: none;
}
Run Code Online (Sandbox Code Playgroud)
有什么建议?
css ×4
javascript ×3
css3 ×2
flexbox ×2
html ×2
ajax ×1
c++ ×1
dns ×1
google-api ×1
google-oauth ×1
heroku ×1
jquery ×1
reactjs ×1
simple-form ×1