このサイトをもとにドロップダウンメニューの作成を考えています。
http://ooigawa-bitter-sweet.hatenablog.com/entry/2015/04/12/233000
cssだけでjavascriptを使わずに作りたいのですが、不可能でしょうか?
何度かcssだけでドロップダウンメニューを作りましたが、できませんでした。
<a href=>の部分をクリックすると、ページの上部にジャンプします。
原因はドロップダウンメニューのリストに表示したい情報がwebapiから取得する情報だからでなないかと思います。自信を持って言えません笑
コードは以下のとおりです。
サイトのように、<ul><li>を使わずに<table><tr><td>を使用しています。
※css
css
1<style> 2 #contents { 3 overflow: hidden; 4 width: 653px; 5 height: 300px; 6 margin: 0 auto; 7} 8#nav { 9 float: left; 10 list-style: none; 11 width: 108px; 12} 13
※php
PHP
1<?php 2$key='My Key'; 3$count='10'; 4$large_area='〇〇'; 5$start =1; 6$format='xml'; 7$url='http://webservice.recruit.co.jp/hotpepper/gourmet/v1/?key='.$key.'&count='.$count.'&large_area='.$large_area.'&start='.$start.'&format='.$format; 8$xml=simplexml_load_file($url); 9$total_count=$xml->results_available; 10if(!$xml->shop){ 11 echo 'we can't find'; 12 } else { 13 foreach($xml->shop as $r){ 14echo '<table>'; 15 echo '<tr>'; 16 echo '<th>'; 17 echo '店名'; 18 echo '</th>'; 19 echo '<td>'; 20 echo $r->name; 21 echo '</td>'; 22 echo '</tr>'; 23 echo '<tr id="contents">'; 24 echo '<th id="nav">'; 25 echo '<a href="#">'; 26 echo 'ジャンル'; 27 echo '</a>'; 28 echo '</th>'; 29 echo '<td colspan="2">'; 30 echo '<a href="#">'; 31 echo $r->genre->catch; 32 echo '</a>'; 33 echo '</td>'; 34 echo '</tr>'; 35 echo '<tr>'; 36 echo '<th>'; 37 echo '禁煙'; 38 echo '</th>'; 39 echo '<td>'; 40 echo $r->non_smoking; 41 echo '</td>'; 42 echo '</tr>'; 43 echo '</table>'; 44 } 45} 46?> 47 48
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/01 17:16