如何解决这个跨浏览器问题?

时间:2013-05-30 07:56:00

标签: jquery css cross-browser

当我在Crome中运行我的代码时,它看起来像view in crome

当我在Firefox中运行它时,它看起来像

view in firefox

我希望火狐视野无处不在。我该如何解决这个问题。我的代码如下所示

@{
    ViewBag.Title = "Home Page";
}
<link href="../../Content/css/jq.stopwatch.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/js/jq.stopwatch.js" type="text/javascript"></script>

<input type="submit" id="createNew" name="AddNewTask" value="Add New Task" />
<div id="form">

</div>
<div id="tasks">

</div>

<style>
    #createNew {
       margin-left : 450px;
        margin-bottom : 10px ;
    }
    #taskDiv{
        background-color: #669900;
        height: 300px;
        width: 240px;
        float: left;
        border-radius: 8px;
        margin-left: 25px;
        margin-bottom: 10px;
    }
    #taskNameId {
        color : white ;
        margin: 5px 15px 15px 5px;
    }
    #taskCategoryId {
        color : white ;
         margin: 5px 15px 5px 5px;
    }
    .timerDiv {
         color : white ;
         margin: 5px 15px 5px 36px;
    }
    #taskDescriptionId{
        color : white ;
         margin: 5px 15px 5px 5px;
    }
    #taskDescriptiontextareaId {
        margin-left: 18px;
        width : 200px ;
        border-radius : 10px ;
    }

    #taskListId {
        margin-left : 20px ;
        border-radius: 10px;
        width : 124px ;
    }
    #taskCategoryListId {
        border-radius: 10px;
        width : 124px ;
    }
</style>
<script type="text/javascript">
    var counter = 0;

    $("#createNew").click(function () {
        $(".closed").css("background-color", "#0099CC");
        $(".closed").css("height", "200");
        $(".dropdownClass").attr("disabled", "disabled");
        $(".taskDescriptiontextareaClass").attr("disabled", "disabled");
        $("#stopwatch").replaceWith('<div class="timerDiv">'+"Time Duration:" + $(".hr").html() + ":" + $(".min").html() + ":" + $(".sec").html() + '</div>');
        createNewTask().appendTo("#main");
        var mainHeight = $("#main").css("height");
        if (mainHeight <= '300px' || (counter % 4 == 0)) {
            $("#main").css("height", parseInt(mainHeight) + 300 + 'px');
        }
        counter++;

    });

    function createNewTask() {
        var newDiv = $('<div>')
            .attr({ Class:'closed',id: 'taskDiv' });
        newDiv.append(createTask());
        newDiv.append(createTaskCategory());
        newDiv.append(createTaskDescription());
        newDiv.append(getStopwatchDiv());
        return newDiv;
    }

    function getStopwatchDiv() {
        var stopwatchDiv = $('<div>').attr({ Class:'stopwatchClass',id: 'stopwatch' });
        stopwatchDiv.stopwatch('theme-1');
        return stopwatchDiv;

    }

    function createTask() {
        var taskName = $('<label>').attr({id:'taskNameId'}).text('Task Name:');
        createTaskDropdown().appendTo(taskName);
        return taskName;
    }

    function createTaskCategory() {
        var taskCategory = $('<label>').attr({ id: 'taskCategoryId' }).text('Task Category:');
        createTaskCategoryDropdown().appendTo(taskCategory);
        return taskCategory;
    }

    function createTaskDescription() {
        var taskDescription = $('<label>').attr({  id: 'taskDescriptionId' }).text('Task Description:');
        var textArea = $('<textarea/>').attr({ Class: 'taskDescriptiontextareaClass', id: 'taskDescriptiontextareaId' });
        textArea.appendTo(taskDescription);
        return taskDescription;
    }

    function createTaskDropdown() {
        var data = ["Select Task", "TaskA", "TaskB", "TaskC"];
        var taskList = $('<select />').attr({ Class:'dropdownClass',id: 'taskListId' });

        for (var val in data) {
            $('<option />', { value: val, text: data[val] }).appendTo(taskList);
        }
        return taskList;
    }

    function createTaskCategoryDropdown() {
        var data = ["Select Task ", "CategoryA", "CategoryB", "CategoryC"];
        var taskCategoryList = $('<select />').attr({ Class: 'dropdownClass', id: 'taskCategoryListId' });

        for (var val in data) {
            $('<option />', { value: val, text: data[val] }).appendTo(taskCategoryList);
        }
        return taskCategoryList;
    }

</script>

1 个答案:

答案 0 :(得分:3)

同时使用border-radius的供应商前缀版本。例如:

border-radius: 8px;

应改为:

-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
Chrome已暂时支持

border-radius一段时间,因此您必须使用旧版本。