我正在努力实现,当有人访问我的wordpress页面时,加载了他的语言的.po(语言)包.目前,可以通过向URL添加?lang =参数来更改语言.但我希望根据浏览器语言选择正确的语言.
我的代码:
<?php
// start the session
session_start();
$browserlang = " ".$_SERVER['HTTP_ACCEPT_LANGUAGE'];
// if there's a "lang" parameter in the URL...
if( isset( $_GET[ 'lang' ] ) ) {
// ...set a session variable named WPLANG based on the URL parameter...
$_SESSION[ 'WPLANG' ] = $_GET[ 'lang' ];
// ...and define the WPLANG constant with the WPLANG session variable
$locale = $_SESSION[ 'WPLANG' ];
echo 'Based on URL parameter';
// if there isn't a "lang" parameter in the URL... …Run Code Online (Sandbox Code Playgroud) 我想在背景图像前面显示文本。但它总是会隐藏我的文字。代码是:
HTML:
<div class="header">
<div class="container">
<div class="container-bg">
</div>
<div class="container-content">
<h1>Test Test Test Test Test Test</h1>
<p>Test Test Test Test Test Test Test Test Test Test Test Test</p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
h1 {
font-size: 46px;
color: #ccc
}
p {
font-size: 28px;
color: #ccc
}
.header {
position: relative;
padding: 30px 0;
}
.container-bg {
position: absolute;
top: 0;
bottom: -60px;
right: 0;
left: 0;
background-image:
linear-gradient(to right, rgba(0,0,0,1) 0%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 100%),
url(https://i2.wp.com/www.pro-gamer-gear.de/wp-content/uploads/2014/08/gamer-pc-zusammenstellen.jpg?fit=1170%2C700);
background-size: cover;
}
.container-content { …Run Code Online (Sandbox Code Playgroud)