我正在使用此代码在一个区域中随机移动图像.但我总是要展示至少3张图片.这是我做的:
HTML
<div class="fade">Image 1</div>
<div class="fade">Image 2</div>
<div class="fade">Image 3</div>
<div class="fade">Image 4</div>
<div class="fade">Image 5</div>
<div class="fade">Image 6</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
(function fadeInDiv() {
var divs = jQuery('.fade');
var elem = divs.eq(Math.floor(Math.random() * divs.length));
if (!elem.is(':visible')) {
elem.prev().remove();
elem.fadeIn(Math.floor(Math.random() * 1000), fadeInDiv);
} else {
elem.fadeOut(Math.floor(Math.random() * 1000), function() {
elem.before('<div> </div>');
fadeInDiv();
});
}
})();
Run Code Online (Sandbox Code Playgroud)
这个代码随机显示fadein和fadeout图像,结果一次显示2个图像,有时一次显示1个图像.我需要每次使用fadein淡出功能显示3个图像,每个图像有6个图像.
以下是我的主页的样子:
Image1 Image2
Image3
Run Code Online (Sandbox Code Playgroud)
我希望它看起来像:
Image1
Image2 Image3
Run Code Online (Sandbox Code Playgroud)
要么
Image1
Image2 Image3
Run Code Online (Sandbox Code Playgroud)
或此图像的任何其他模式
我是drupal 8的新手,想在我的drupal 8网站上添加meta标签.
我这样做了:
在我的THEME.theme文件中添加了以下代码
/**
* Implements hook_page_attachments_alter().
*
* Include meta tags and fonts using attachment method.
*/
function bartik_page_attachments_alter(array &$page) {
// echo "<pre>"; echo "BEFORE"; print_r($page);
// Include fonts.
$font_attributes = array(
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => 'https://fonts.googleapis.com/css?family=Lato:400,100,100italic,300,300italic,400italic,700',
);
$page['#attached']['html_head_link'][] = array($font_attributes);
// Set up meta tags.
// Modern IE & chrome-frame rendering engine tag.
$rendering_meta = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'SKYPE_TOOLBAR',
'content' => 'SKYPE_TOOLBAR_PARSER_COMPATIBLE', …Run Code Online (Sandbox Code Playgroud)这是我的数组:
Array
(
[0] => Array
(
[id] => 8
[title] => MUSIC
)
[1] => Array
(
[id] => 17
[title] => Indie
)
[2] => Array
(
[id] => 14
[title] => SPORTS
)
[3] => Array // Need to move this on first position
(
[id] => 15
[title] => Hipster
)
[4] => Array
(
[id] => 16
[title] => Web Seriesdf
)
)
Run Code Online (Sandbox Code Playgroud)
我希望带有键 [3] 的数组位于第一个位置,然后是其余元素。我尝试了 array_merge 和 array_unshift。但不工作
我想存储:
在我的名为products_data的表中,其filds名称为PID,product_name,category,subcategory,product_price和product_company.
我curl_init()在php中使用函数首先废弃网站URL,接下来我想将产品数据存储在我的数据库表中.以下是我迄今为止所做的事情:
$sites[0] = 'http://www.babyoye.com/';
foreach ($sites as $site)
{
$ch = curl_init($site);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
$title_start = '<div class="info">';
$parts = explode($title_start,$html);
foreach($parts as $part){
$link = explode('<a href="/d/', $part);
$link = explode('">', $link[1]);
$url = 'http://www.babyoye.com/d/'.$link[0];
// now for the title we need to follow a similar process:
$title = explode('<h2>', $part);
$title = explode('</h2>', $title[1]);
$title = strip_tags($title[0]);
// INSERT DB CODE HERE e.g.
$db_conn = …Run Code Online (Sandbox Code Playgroud)