我正在使用一个小应用程序,其中包含国家和标志的项目符号列表。该列表最初使用的是常规子弹图标,但我也希望包含标志。应用程序中有2个区域影响列表,第一个是index.php文件(我更改了代码以选择标记图像。该文件的全部内容如下:
jQuery(document).ready(function($) {
$("li").click(function() {
parent.addLanguageCode();
var b = $('.arrowchat_trayclick').attr('id');
b = b.substr('30');
var info = $(this).attr('id');
if (info != b) {
$('.goog-te-combo', top.document).val(info);
parent.changeLanguage();
$('#arrowchat_applications_button_' + b).click();
$('#arrowchat_applications_button_' + b + ' img').attr('src', '{$base_url}images/' + info + '.png');
$('#arrowchat_app_link_' + b + ' img').attr('src', '{$base_url}images/' + info + '.png');
$.cookie('arrowchat_language_app', info);
}
});
});
html,
body {}
.small {
font-weight: bold;
}
.translate_ul ul {
float: left;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
}
.translate_ul li {
text-align: left;
float: left;
width: 102px;
margin: 0;
height: 20px;
background-position: 0 -1px;
background-repeat: no-repeat;
padding: 0 0 0 1.5em;
cursor: pointer;
}
.translate_container {
background-color: #fffff;
color: #333;
font-weight: normal;
font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;
font-size: 11px;
padding: 15px 10px;
padding-bottom: 0px;
text-align: left;
}
.translate_container a {
color: #11648F;
}
.translating {
display: none;
}
<!--
<?php #PHP bits from the op, left here but useless for a snippet
require_once(dirname(__FILE__)."/config.php");
// Gets the folder path without filename
function GetFileDir($php_self) {
$filename2 = "";
$filename = explode("/", $php_self);
for( $i = 0; $i < (count($filename) - 1); ++$i ) {
$filename2 .= $filename[$i].'/';
}
return $filename2;
}
$base_url = GetFileDir($_SERVER['PHP_SELF']);
echo <<<EOD
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" media="all" href="{$base_url}includes/css/style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="{$base_url}includes/js/jquery.cookie.js" type="text/javascript"></script>
<script src="{$base_url}includes/js/functions.js" type="text/javascript"></script>
<div style="width:100%;margin:0 auto;margin-top: 0px;height:300px" class="translate_ul">
<div class="translate_container" style="height:300px;">
<ul class="languages" style="height: 300px;">
<li id="af"><img src="/arrowchat/applications/translate/images/af.png" alt="af" />Afrikaans</li>
<li id="sq"><img src="/arrowchat/applications/translate/images/sq.png" alt="sq" />Albanian</li>
<li id="ar"><img src="/arrowchat/applications/translate/images/ar.png" alt="ar" />Arabic</li>
<li id="be"><img src="/arrowchat/applications/translate/images/be.png" alt="be" />Belarusian</li>
<li id="bg"><img src="/arrowchat/applications/translate/images/bg.png" alt="bg" />Bulgarian</li>
<li id="ca"><img src="/arrowchat/applications/translate/images/ca.png" alt="ca" />Catalan</li>
<li id="zh-CN"><img src="/arrowchat/applications/translate/images/zh-CN.png" alt="zh-CN" />Chinese (Simple)</li>
<li id="zh-TW"><img src="/arrowchat/applications/translate/images/zh-TW.png" alt="zh-TW" />Chinese (Traditional)</li>
<li id="hr"><img src="/arrowchat/applications/translate/images/hr.png" alt="hr" />Croatian</li>
<li id="cs"><img src="/arrowchat/applications/translate/images/cs.png" alt="cs" />Czech</li>
<li id="da"><img src="/arrowchat/applications/translate/images/da.png" alt="da" />Danish</li>
<li id="nl"><img src="/arrowchat/applications/translate/images/nl.png" alt="nl" />Dutch</li>
<li id="en"><img src="/arrowchat/applications/translate/images/en.png" alt="en" />English</li>
<li id="et"><img src="/arrowchat/applications/translate/images/et.png" alt="et" />Estonian</li>
<li id="tl"><img src="/arrowchat/applications/translate/images/tl.png" alt="tl" />Filipino</li>
<li id="fi"><img src="/arrowchat/applications/translate/images/fi.png" alt="fi" />Finnish</li>
<li id="fr"><img src="/arrowchat/applications/translate/images/fr.png" alt="fr" />French</li>
<li id="gl"><img src="/arrowchat/applications/translate/images/gl.png" alt="gl" />Galician</li>
<li id="de"><img src="/arrowchat/applications/translate/images/de.png" alt="de" />German</li>
<li id="el"><img src="/arrowchat/applications/translate/images/el.png" alt="el" />Greek</li>
<li id="ht"><img src="/arrowchat/applications/translate/images/ht.png" alt="ht" />Haitian Creole</li>
<li id="iw"><img src="/arrowchat/applications/translate/images/iw.png" alt="iw" />Hebrew</li>
<li id="hi"><img src="/arrowchat/applications/translate/images/hi.png" alt="hi" />Hindi</li>
<li id="hu"><img src="/arrowchat/applications/translate/images/hu.png" alt="hu" />Hungarian</li>
<li id="is"><img src="/arrowchat/applications/translate/images/is.png" alt="is" />Icelandic</li>
<li id="id"><img src="/arrowchat/applications/translate/images/id.png" alt="id" />Indonesian</li>
<li id="ga"><img src="/arrowchat/applications/translate/images/ga.png" alt="ga" />Irish</li>
<li id="it"><img src="/arrowchat/applications/translate/images/it.png" alt="it" />Italian</li>
<li id="ja"><img src="/arrowchat/applications/translate/images/ja.png" alt="ja" />Japanese</li>
<li id="ko"><img src="/arrowchat/applications/translate/images/ko.png" alt="ko" />Korean</li>
<li id="lv"><img src="/arrowchat/applications/translate/images/lv.png" alt="lv" />Latvian</li>
<li id="lt"><img src="/arrowchat/applications/translate/images/lt.png" alt="lt" />Lithuanian</li>
<li id="mk"><img src="/arrowchat/applications/translate/images/mk.png" alt="mk" />Macedonian</li>
<li id="ms"><img src="/arrowchat/applications/translate/images/ms.png" alt="ms" />Malay</li>
<li id="mt"><img src="/arrowchat/applications/translate/images/mt.png" alt="mt" />Maltese</li>
<li id="no"><img src="/arrowchat/applications/translate/images/no.png" alt="no" />Norwegian</li>
<li id="fa"><img src="/arrowchat/applications/translate/images/fa.png" alt="fa" />Persian</li>
<li id="pl"><img src="/arrowchat/applications/translate/images/pl.png" alt="pl" />Polish</li>
<li id="pt"><img src="/arrowchat/applications/translate/images/pt.png" alt="pt" />Portuguese</li>
<li id="ro"><img src="/arrowchat/applications/translate/images/ro.png" alt="ro" />Romanian</li>
<li id="ru"><img src="/arrowchat/applications/translate/images/ru.png" alt="ru" />Russian</li>
<li id="sr"><img src="/arrowchat/applications/translate/images/sr.png" alt="sr" />Serbian</li>
<li id="sk"><img src="/arrowchat/applications/translate/images/sk.png" alt="sk" />Slovak</li>
<li id="sl"><img src="/arrowchat/applications/translate/images/sl.png" alt="sl" />Slovenian</li>
<li id="es"><img src="/arrowchat/applications/translate/images/es.png" alt="es" />Spanish</li>
<li id="sw"><img src="/arrowchat/applications/translate/images/sw.png" alt="sw" />Swahili</li>
<li id="sv"><img src="/arrowchat/applications/translate/images/sv.png" alt="sv" />Swedish</li>
<li id="th"><img src="/arrowchat/applications/translate/images/th.png" alt="th" />Thai</li>
<li id="tr"><img src="/arrowchat/applications/translate/images/tr.png" alt="tr" />Turkish</li>
<li id="uk"><img src="/arrowchat/applications/translate/images/uk.png" alt="uk" />Ukrainian</li>
<li id="vi"><img src="/arrowchat/applications/translate/images/vi.png" alt="vi" />Vietnamese</li>
<li id="cy"><img src="/arrowchat/applications/translate/images/cy.png" alt="cy" />Welsh</li>
<li id="yi"><img src="/arrowchat/applications/translate/images/yi.png" alt="yi" />Yiddish</li>
</ul>
<div class="translating">
{$translate_language[0]}
</div>
<div style="clear:both"></div>
</div>
</div>
然后有一个css文件,我已经搞乱了几个小时但没有成功:
我的列表输出看起来像附加图像
我想做的就是让国家名称位于旗帜的右侧,但到目前为止我所尝试的并没有成功实现这一目标。
任何人都可以帮助我吗?
亲切的问候
答案 0 :(得分:0)
.translate_ul ul {
float: left;
width: 100%;
margin: 0;
padding: 0; // <= YOU NEED TO ADD LEFT PADDING HERE
list-style: none;
}
我相信解决方案是在你的“ul”元素中添加左边距,尝试考虑标志的宽度。
答案 1 :(得分:0)
好的,这就是我解决问题的方法,请在此处输入:https://embed.plnkr.co/H110p2/
首先。忘记花车,它们几乎被弃用了。我从你的CSS中删除了它们。只有在少数情况下才有必要,而不是为此。
二。在index.html中查看我在<p>
中包含了每个国家/地区名称,因此我可以在css中更轻松地处理它们。
第三,检查css文件,首先我清理.translate_ul li
填充并将其设置为0.然后我为<li>
元素内的图像和<p>
创建了一个处理程序元件。然后我在两个元素中都使用了属性display: inline-block
,这告诉导航器它们在一个旁边对齐,属性:vertical-align: middle
,表示我希望它们在彼此的中间对齐。最后,我在<p>
元素的左侧添加了一个小边距以获得美学。
.translate_ul li {
text-align: left;
width: auto;
margin: 0;
height: 20px;
background-position: 0 -1px;
background-repeat: no-repeat;
padding: 0 0 0 0;
cursor: pointer;
}
.translate_ul li p{
display:inline-block;
vertical-align:middle;
margin-left:5px;
}
.translate_ul li img{
display:inline-block;
vertical-align:middle;
width:16px;
}
我希望这适合你。