ورود

View Full Version : سوال: نمایش عکس های درون فایل css ؟



malihehshajari
شنبه 01 تیر 1392, 10:34 صبح
سلام من یک فایل css دارم که درون اون یکسری عکس ها رو مسیر دهی کردم ولی زمان اجرای برنامه عکس ها نشون داده نمیشن . ( برنامه رو با python , django نوشتم ) :
فایل css :


A { text-decoration: none; }
.button_edit
{
background-image: url({{ MEDIA_URL }}img/edit1.gif) ;
background-position: 0px 0px;
background-repeat: no-repeat;
width: 14px;
height: 14px;
border: 0px;
}

.button
{
background-image: url({{ MEDIA_URL }}img/button.jpg) ;
background-position: 0px 0px;
background-repeat: no-repeat;
width: 100px;
height: 35px;
border: 0px;
color: #000099;
}

.text_rtl { direction:RTL; }

.text_ltr { direction:LTR; }

.button_delete
{
background-image: url({{ MEDIA_URL }}img/delete.gif) ;
background-position: 0px 0px;
background-repeat: no-repeat;
width: 13px;
height: 14px;
border: 0px;
}

.style2 { width: 755px; }

.style4{
width: 741px;
height: 48px;
background-image: url('{{ MEDIA_URL }}img/menu53.jpg');
border-bottom-color: #FFFFFF;
color: #000080;
}

.style5 { width: 255px; }

.style_tb_setting
{
border-color: navy;
background-image: url('{{ MEDIA_URL }}img/line_setting2.JPG');
width: 400 px;
}
.style_tb_search
{
background-image: url('{{ MEDIA_URL }}img/line_search.jpg');
width: 596px;
height: 110px;
}
.style_tb_user
{
background-image: url('{{MEDIA_URL}}img/line_user1.JPG');
height: 350px;
}
.style_tb_doctor
{
height: 310px;
background-image: url('{{ MEDIA_URL }}img/line_dr.JPG');
}


لینک به css درون صفحه اچ تی ام ال :



<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/style.css" />

مسیر دهی درون setting.py :



MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "Template/").replace('\\','/')
MEDIA_URL = '/Template/'


لطفا راهنمایی کنید
با تشکر

Bojbaj
شنبه 01 تیر 1392, 15:44 عصر
برای عکس ها آدرس دهی نسبی استفاده کن
نیازی به این کار نیست ( که توی CSS اصلا جواب هم نمیده )
با توجه به کدی که دادی فایل Style.css توی پوشه CSS و عکس ها توی پوشه img هستن. پس اینجوری استفاده کن :
background-image: url('../img/line_dr.JPG');