htmlファイルに直<style>接書く,新たに<head>に新ファイルを作成したら反映されるが
既存の読み込んでいるcssファイルに書きもむと動きません。
以前の質問にてcssの喧嘩について解説ついただいた時は
ファイルの読み込み順や宣言優先度にて解決できたのですが
今回はimportantなどを使用しても解決しませんでした。
新たなファイルやhtmlに直接なら動くのに
既存の読み込まれているcssに追加すると反映されない理由の原因はなんでしょうか?
解決策を教えていただきたいです。
反映させたいコード
css
1img.imgView{ 2 width: 200px;/* トリミングしたい枠の幅 */ 3 height: 200px;/* トリミングしたい枠の高さ */ 4 object-fit: cover; 5}
現在のコード
js
1 $.ajax({ 2 url: "/ninnin/hogehoge/add", 3 type: 'POST', 4 dataType: 'text', 5 data: formData, 6 cache: false, 7 contentType: false, 8 processData: false, 9 xhr: function() { 10 var xhr = $.ajaxSettings.xhr(); 11 if (xhr.upload) { 12 $('#submit').attr('disabled', 'disabled'); 13 xhr.upload.addEventListener('progress', function(evt) { 14 var percent = (evt.loaded / evt.total) * 100; 15 $("#progress-container").find(".progress-bar").width(percent + "%"); 16 17 }, false); 18 } 19 return xhr; 20 }, 21 success: function(imageData, status, xhr) { 22 var res = {}; 23 try { 24 res = $.parseJSON(xhr.responseText); 25 }catch (e) {} 26 $("#image-files ul").append("<img class='imgView' src=\"" + res.img + "\" / >"); 27 $('<input>').attr({ 28 type: 'textarea', 29 name: "body["+res.img_id+"]", 30 value: "", 31 }).appendTo('form'); 32 $('<input>').attr({ 33 type: 'hidden', 34 name: "img["+res.img_id+"]", 35 value: res.img_id, 36 }).appendTo('form'); 37 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/04 03:45