html - Div 技巧内联文本?

标签 html css

我是初学者,我正在尝试将 div 显示到我的单选按钮。我在我的代码中解释了这个问题。 ajax 调用后显示自动完成框。

<input type="text" name="search" id="search" autofocus autocomplete="off" />
<input type="submit" id="search_button" title="Check" value="Check"/>

//the suggesstion div move radio button to the right I need it up of the radio buttons !
<div id="suggesstion-box"></div>

<label>Search by :</label>
<input id="radio" name="radio" value="name" type="radio"/>
<span id="radio_text"> name</span>
<input id="radio" name="radio" value="age" type="radio">
<span id="radio_text"/>age</span>

ajax.js 获取数据

$(document).ready(function(){ 
    $("#search").keyup(function(){
            if ($("#search").val() == "")
            $("#suggesstion-box").hide();
        else{
        $.ajax({
        type: "GET",
        url: "getinfo.php",
        data:'keyword='+$(this).val(),
        success: function(data){
                    console.log(data);
            $("#suggesstion-box").show();
                        document.getElementById("suggesstion-box").innerHTML=data;
            //$("#suggesstion-box").html("data");
            $("#search").css("background","#FFF");
        }
        }); 
            }//else box not empty 

    });
        console.log("print it");
});

function select(val) {
$("#search").val(val);
$("#suggesstion-box").hide();
}

getinfo.php 打印数据到意见箱

<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
//include('database.php');
//Sanitize the POST values
$hint = $_GET['keyword'];
$i = 0;

$qry1 = "SELECT * FROM Journals where Journal_name like '" . $hint . "%' AND is_reported=1 LIMIT 3 ";
$qry2 = "SELECT * FROM Publishers where Publisher_Name like '" . $hint . "%' AND is_reported=1 LIMIT 2;";
//$result = mysql_query($qry1);
//$result2 = mysql_query($qry2);

$data = array();
$result2 = $db_handle->runQuery($qry2);
$result1 = $db_handle->runQuery($qry1);
if (!empty($result2)) {
    ?>
    <ul id="country-list">
        <?php
        foreach ($result2 as $info2) {
            ?>
            <li onClick="select('<?php echo $info2['Publisher_Name']; ?>');"><?php echo $info2['Publisher_Name']; ?></li>
        <?php
        } if (empty($result1)){
            ?>
        </ul>
        <?php  } }
    if (!empty($result1)) {
        if (empty($result2)){

            ?>
        <ul id="country-list">
        <?php
        }
            foreach ($result1 as $info) {
                ?>
                <li onClick="select('<?php echo $info['Journal_name']; ?>');"><?php echo $info['Journal_name']; ?></li>
        <?php } ?>
        </ul>
<?php
}
?>

s.css

#country-list{float:left;list-style:none;margin:0;padding:0;width:210px; display: inline;}
#country-list li{padding: 10px; background:#FAFAFA;border-bottom:#F0F0F0 1px solid;}
#country-list li:hover{background:#F0F0F0;}
#search {
    width: 300px;
    height: 10px;
    border: thin solid #00B6A8;
    margin-top: 10px;
    font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
    border-collapse: collapse;
    -webkit-box-shadow: 0px 0px 2px;
    box-shadow: 0px 0px 2px;
    padding: 10px;
    display: inline;
        //border: #F0F0F0 1px solid;
}
#suggesstion-box {
    display: inline;
}
#radio {
    margin-top: 10px;
    margin-left: 30px;
}
#radio_text {
    color: #545454;
    font-size: normal;
    font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
    font-style: normal;
    font-weight: normal;
}
#label {
    /*margin-left: -210px;*/
    color: #00B6A8;
    font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
    font-weight: normal;
    font-size: medium;
}

最佳答案

尝试:

<div id="suggesstion-box"></div>

<div class="wrapper">
    <label>Search by :</label>
    <input id="radio" name="radio" value="name" type="radio"/>
    <span id="radio_text"> name</span>
    <input id="radio" name="radio" value="age" type="radio">
    <span id="radio_text"/>age</span>
</div>

在 CSS 中:

.wrapper {
position: absolute;
}

关于html - Div 技巧内联文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34213717/

相关文章:

python - 正则表达式 : Find Names in String using Python

jquery - 使用 Jquery 更改 CSS,如何保留规则的一部分

html - 如何处理移动设备中的不同分辨率(Retina 和 HD)?

jquery - 调整浏览器窗口大小时自动更改框的宽度?

html - 悬停后更改其他表格元素的样式

javascript - 有人知道 twiddla 是如何实现其浏览功能的吗?

javascript - KineticJS toImage 宽度和高度问题

css - block 不是内联的

javascript - PHP:在文件夹中找不到上传的图像

html - 面包屑标记 - 主页和当前页面?